Java and JUnit, find missing @Test decorators

Veslav :

Let's say we have a project full of unit tests (thousands) and they all should look like this

@Test
public void testExceptionInBla() {
   // some test
}

But in one case someone forgot to put an @Test decorator on top of the test.

What would be an easy way to spot those tests, without looking through all the code manually?

I want to find code like this, it's a test without @Test:

public void testExceptionInBla() {
   // some test
}
Łukasz Ozimek :

I were you I would look at some Sonnar rule here I found something that may can match requirement: https://rules.sonarsource.com/java/RSPEC-2187

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=10192&siteId=1