简体   繁体   中英

maven surefire plugin not picking up test

I have a simple Maven project, and have a test class called IntegrationTest.

When I execute: mvn surefire:test , the test gets executed. However, the same test is completely ignored when I execute a standard Maven build: mvn package

Am I missing anything?

ADDITIONAL INFORMATION (May 24th):

I tried to follow advice by @dragan-bozanovic, but inexplicably, without any changes, my tests are not called under any condition anymore. I'm stumped. I committed a project here: https://github.com/javalite/activeweb The tests are not invoked in this module: https://github.com/javalite/activeweb/tree/master/activeweb-lessc-integration-test

I tried JUnit 3 style, JUnit4 style, changed names of classes, moved to different package - no avail. When I execute mvn install , I do not see that surefire plugin is called. When I call it explicitly: mvn surefire:test , it puts out a message: No tests to run

Any help is much appreciated!

The real reason for surefire plugin not be able to find tests, is because my pom.xml file had <packaging>pom</packaging> . As soon as I switched it to <packaging>jar</packaging> , surefire plugin picked up the tests. In any case, Dragan - thank you for pushing me in the right direction!

According to Maven default build lifecycle , integration tests come after the package phase. It may be that a naming convention is used here, because your test class name ends with IntegrationTest .

If this is really not an integration test, then rename the class accordingly. If it is, then it seems that Maven behaves as described.

EDIT

It may also be that a wrong combination of versions of surefire, JUnit and JUnit-style of tests is used. More info about this can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM