There are several solutions possible using a regular expression. The simplest one is having the configuration
<includes>
<include>*AnotherSomeTest.java</include>
<include>%regex[.*(?<!Some)Test\.class]</include>
</includes>
This will match tests where the class name ends either with AnotherSomeTest
, or with Test
but not preceded by Some
(the negative lookbehind <
just needs to be properly escaped with <
). Note that the regular expression match is done over the .class
file, while the traditional one is done over the .java
file.
You could put this into a single regular expression, with
<include>%regex[.*(?<!(?<!Another)Some)Test\.class]</include>
which selects all tests ending with Test
, not preceded by Some
themselves not preceded by Another
, although it's probably not clearer.
Another alternative is to use multiple formats into one, that works since version 2.19 of the plugin and JUnit 4 or TestNG. This is useful for the command line notably:
<include>%regex[.*(?<!Some)Test\.class], *AnotherSomeTest.java</include>