Maven does not find JUnit tests to run
By default Maven uses the following naming conventions when looking for tests to run:
Test*
*Test
*Tests
(has been added in Maven Surefire Plugin 2.20)*TestCase
If your test class doesn't follow these conventions you should rename it or configure Maven Surefire Plugin to use another pattern for test classes.
UPDATE:
Like @scottyseus said in the comments, starting from Maven Surefire 2.22.0 the following is sufficient:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version></plugin>
When using JUnit 5, i ran into the same problem. Maven Surefire needs a plugin to run JUnit 5 tests. Add this to our pom.xml
:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.21.0</version> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.2.0-M1</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0-M1</version> </dependency> </dependencies></plugin>
Source:https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven
UPDATE 2021
The junit-platform-surefire-provider, which was originally developed by the JUnit team, was deprecated in JUnit Platform 1.3 and discontinued in 1.4. Please use Maven Surefire’s native support instead.