I’m trying to create a custom Checkstyle rule which will flag as an error when developers use @Ignore without a comment. Therefore I’m looking for a regular expression which matches the following scenario:
@Ignore
@Test
public void someTest() {
...
}
and this one:
@Ignore @Test //or @Test @Ignore
public void someTest() {
...
}
but would not match this scenario:
@Ignore("some comment detailing why this test was ignored")
@Test
public void someTest() {
...
}
or this one:
@Test
public void someTest() {
...
}
So basically its a regular expression matching @Ignore but only when its present and only when its present without qualifying comments, e.g. @Ignore("commnent here")
matches
@Ignoreonly if it’s not followed by an opening parenthesis.Explanation:
In Java: