Maven surefire 2.12 does not run a custom test using the -Dtest parameter

After updating all my Maven plugins for the project, I ran into the following problem: when I run the basic command mvn test -Dtest=SomeTest , the assembly ends without any test. In fact, I cannot run any test using the -Dtest parameter (of course, the test exists and is executed when I just do the mvn test ).

After some searches, it turns out that the problem is with the surefire 2.12 plugin. I tested several versions of Maven (2.2.1 / 3.0.2) and JUnit (4.7.x, 4.8, 4.10 or even 3.8.x), but they do not affect my problem.

So, maybe my project has some specific configurations that can affect this? Anyway, I created a new project using mvn archetype:generate (using the base org.apache.maven.archetypes: maven-archetype-quickstart).

I changed only 2 things in pom.xml : using JUnit 4.10 (but did not change anything, I tried with other versions) and determined the surefire version:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo</groupId> <artifactId>bar</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.11</version> </plugin> </plugins> </build> </project> 

I run mvn test -Dtest=AppTest (by default, the JUnit test created by the archetype):

 ------------------------------------------------------- TESTS ------------------------------------------------------- Running foo.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] 

Now I modify pom.xml to use version 2.12 for Surefire and run the command again:

 ------------------------------------------------------- TESTS Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.907s [INFO] Finished at: Fri Mar 02 10:37:12 CET 2012 [INFO] Final Memory: 3M/15M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project bar: No tests were executed! (Set -D failIfNoTests=false to ignore this error.) -> [Help 1] 

The test this time fails: (

As far as I know, I consider this a regression, but it is rather surprising. Indeed, a JIRA defect is written to Surefire version 2.12, and in this description they manage to use the -Dtest parameter.

Am I doing something wrong? Or is it a real regression (in this case I will create a JIRA)?

Thanks.

+8
maven maven-surefire-plugin
source share
1 answer

This is a bug in version 2.12 - SUREFIRE-827 .

+13
source share

All Articles