Home > Mobile >  Maven surefire plugin DOES NOT run single test, out of many
Maven surefire plugin DOES NOT run single test, out of many

Time:11-05

I have a maven project (multimodule, JDK 11) that has a lot of modules and tests within it.

I suddenly noticed that one of my tests is NOT invoked as part of the surefire plugin. Other tests in the same module do get to be invoked successfully. I am able to run this test successfully via Intellij. The test is not disabled nor ignored. it contains a set of @Test methods. In addition, I am able to run it specifically using mvn test -Dtest=... argument.

The test class gets to be compiled successfully and appears in target/test-classes. (I have already run with -X and could not find relevant additional data there)

I am working with surefire plugin 2.22.1 ; junit-vintage-engine:5.2.0 ; junit-platform-runner:1.2.0 ; Spring Boot 2.5.3 (with BOM) ; My test is spring based and invoked using @ExtendWith(SpringExtension.class) (I do have other spring based tests that are invoked as expected though).

Following this question, I have also tried to work with 2.22.2. It did not solve the problem

Following this question, I have verified and indeed all tests in the test class that does not invoke are prefixed with the 'test' word

EDIT: The problem happens in a test that belongs to a module that is part of a larger project in my company, which inherits various defaults across the POM inheritance chain. Unfortunately, I can not isolate only my POM out of it and present it. I have tried to reproduce the problem in a new isolated project but did not succeed (that is, all the tests were invoked as expected).

What am I missing? Is there a hidden switch of the surefire plugin that reveals what's going on under the hood and where do surefire pull the list of tests he is meant to execute?

CodePudding user response:

The surefire plugin (by default) will run only tests with the following name syntax ...

"**/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".
"**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests".
"**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".

More details can be found here

CodePudding user response:

Problem solved! Following @Kathrin Geilmann comment:

...By default surefire only executes: ...Test.java, Test....java, ...Tests.java and ...TestCase.java

The name of my file ended with ...Tester (!@#$$%^)

Thanks.

  • Related