Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven test isn't picking up JUnit 4 Tests unless class ends with Test on a multi-module project

Apache Maven 3.0 (r1004208; 2010-10-04 12:50:56+0100)

running

mvn test

ignores any JUnit 4 tests unless the name of the class is *Test.

Having just a single dependency to junit-4.8.2 and target/source configured to be 1.6

like image 927
qnoid Avatar asked Feb 08 '11 14:02

qnoid


People also ask

How do I run a JUnit test in Maven?

We can run our unit tests with Maven by using the command: mvn clean test. When we run this command at command prompt, we should see that the Maven Surefire Plugin runs our unit tests. We can now create a Maven project that compiles and runs unit tests which use JUnit 5.

Why Maven surefire plugin tests are skipped?

When the Surefire plugin reaches the test goal, it will skip the unit tests if the maven. test. skip properties is set to true . Another way to configure Maven to skip unit tests is to add this configuration to your project's pom.

Does JUnit 4 run tests in parallel?

Yes, You can. Show activity on this post. JUnit Toolbox provides JUnit runners for parallel execution of tests.


1 Answers

That's the standard configuration in the maven surefire plugin.

By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:

  • "*/Test.java" - includes all of its subdirectories and all java filenames that start with "Test".
  • "**/*Test.java" - includes all of its subdirectories and all java filenames that end with "Test".
  • "**/*TestCase.java" - includes all of its subdirectories and all java filenames that end with "TestCase".

Source: Inclusions and Exclusions of Tests (this article also shows how you can add additional test class patterns).

like image 127
Sean Patrick Floyd Avatar answered Sep 23 '22 09:09

Sean Patrick Floyd