Maven 2 does not seem to consider my @Test and @Ignore annotations. How do I configure the surefire plugin to run and use the annotations?
This question is still not answered.
I would first configure your master POM to default the surefire plugin to the latest version. This is done by adding an entry to the plugin management section of the POM. For example:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
</plugin>
</plugins>
</pluginManagement>
All child POMs will now be configured with this version of the plugin, which supports JUnit 4.x annotations.
If that doesn't work, then I would make sure your JUnit test files match the naming pattern(s) the surefire plugin expects, which by default are: **/Test*.java, **/*Test.java, and **/*TestCase.java. I like naming my JUnit classes like *Tests.java, so I tweak the plugin like so:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With