Maven does not find JUnit tests to run

For the tests in your project to work, certain settings are necessary. Here are some guidelines for avoiding basic mistakes.

1. Default configuration

By default Maven uses the following naming conventions when looking for tests to run:

  • **/Test*.java
  • **/*Test.java
  • **/*Tests.java
  • **/*TestCase.java

2. Specify names of tests in the command line

  • Running a Single Test

  • Running a Set of Methods in a Single Test Class

As of Surefire 2.7.3, you can also run only a subset of the tests in a test class.

NOTE : This feature is supported only for Junit 4.x and TestNG. Use syntax e.g. “foo/MyTest.java”, “**/MyTest.java”, “MyTest” for “test” parameter .

You should use the following syntax:

You can use patterns too

Since of Surefire Plugin 2.19 you can select multiple methods (JUnit 4, JUnit 4.7+ and TestNG):

  • Multiple Formats in One

As of Surefire Plugin 2.19 multiple formats are supported in one pattern (JUnit 4, JUnit 4.7+, TestNG):

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.