Skip to content
Advertisement

Surefire maven plugin does not execute one of the tests

I have a project with four packages. With three of them everything is fine. I have generated JUnit tests and they are executed during the build or while I am running mvn test command.
But my fourth package, containing just one class. I have created a JUnit test for it, but when I am running the build, Surefire does not see this test class. All other eight test classes are executed, but this one is ignored.
When I am trying to execute just this one test class explicitly using

mvn -Dtest=com.company.dpt.prj.pkg.MySpecificClassTest test

I am getting these messages

JavaScript

I went through the test code line by line and couldn’t find any reasons for such behavior.
I even deleted the test file and regenerated a very basic one. It is still not executed.
Has anyone encountered something similar? Any hint will be greatly appreciated, as I couldn’t find any clues. I am using JUnit 4.11

JavaScript

All tests were originally generated using Netbeans v.12 “Tools->Create/Update Test” and than edited to reflect methods functionality. However, all test but this one are working fine both in Netbeans GUI and CLI “mvn test”. This one is ignored. The purpose of method I want to test is to build HttpEntity for the REST API client. Here is the code of the test:

JavaScript

My problem is that it is not failing within the test code. I will be happy if it would, because I will be able to debug it than. It is just not executing. I tried to upgrade JUnit to v.4.13.1 and surefire maven plugin to v.3.0.0-M5 but it did not have any affect.

I tried to run mvn with -e option and got the following stack trace, but it still did not give me any clues on why it is happening.

JavaScript

Advertisement

Answer

I did find the cause of the problem. Somehow, when IDE generated (and regenerated) that test file it placed the wrong import for the @Test annotation. Instead of

JavaScript

it placed

JavaScript

Therefore, jupiter engine, ran by surefire did not recognized @Test annotation. After I corrected import test was executed.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement