简体   繁体   English

Maven的Surefire插件没有拿起测试

[英]maven surefire plugin not picking up test

I have a simple Maven project, and have a test class called IntegrationTest. 我有一个简单的Maven项目,并且有一个名为IntegrationTest的测试类。

When I execute: mvn surefire:test , the test gets executed. 当我执行: mvn surefire:test ,将执行测试。 However, the same test is completely ignored when I execute a standard Maven build: mvn package 但是,当我执行标准的Maven构建时,将完全忽略同一测试: mvn package

Am I missing anything? 我有什么想念的吗?

ADDITIONAL INFORMATION (May 24th): 其他信息 (5月24日):

I tried to follow advice by @dragan-bozanovic, but inexplicably, without any changes, my tests are not called under any condition anymore. 我试图遵循@ dragan-bozanovic的建议,但莫名其妙地,没有任何更改,我的测试在任何情况下都不再被调用。 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 我在这里提交了一个项目: https : //github.com/javalite/activeweb该模块未调用测试: 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. 我尝试了JUnit 3样式,JUnit4样式,更改了类的名称,移到了不同​​的程序包-无济于事。 When I execute mvn install , I do not see that surefire plugin is called. 当我执行mvn install ,我看不到调用了surefire插件。 When I call it explicitly: mvn surefire:test , it puts out a message: No tests to run 当我显式调用它时: mvn surefire:test ,它发出一条消息: 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> . surefire插件无法找到测试的真正原因是因为我的pom.xml文件具有<packaging>pom</packaging> As soon as I switched it to <packaging>jar</packaging> , surefire plugin picked up the tests. 一旦将其切换到<packaging>jar</packaging> ,surefire插件就会进行测试。 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. 根据Maven的默认构建生命周期 ,集成测试在软件包阶段之后进行。 It may be that a naming convention is used here, because your test class name ends with IntegrationTest . 因为您的测试类名称以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. 如果是这样,那么看来Maven的行为符合描述。

EDIT 编辑

It may also be that a wrong combination of versions of surefire, JUnit and JUnit-style of tests is used. 也可能是使用了surefire,JUnit和JUnit风格的测试版本的错误组合。 More info about this can be found here . 有关此的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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