Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 为什么<;排除组>;工作,但<;团体>;不是吗?_Maven_Testing_Junit_Integration Testing_Smoke Testing - Fatal编程技术网

Maven 为什么<;排除组>;工作,但<;团体>;不是吗?

Maven 为什么<;排除组>;工作,但<;团体>;不是吗?,maven,testing,junit,integration-testing,smoke-testing,Maven,Testing,Junit,Integration Testing,Smoke Testing,我试图使用JUnit和概要文件的@Category-注释来拆分集成测试和冒烟测试。因此,如果我运行mvn clean install-P冒烟测试,则只执行冒烟测试,如果我运行mvn clean install则每次测试都会运行 问题是: 当我用排除Maven中的组时,它会按预期排除这些组。但是当我尝试将它们包含在中时,它仍然会运行每个测试。Maven代码一点也不奇怪: <profile> <id>smoke-tests</id> <act

我试图使用JUnit和概要文件的
@Category
-注释来拆分集成测试和冒烟测试。因此,如果我运行
mvn clean install-P冒烟测试
,则只执行冒烟测试,如果我运行
mvn clean install
则每次测试都会运行

问题是:

当我用
排除Maven中的组时,它会按预期排除这些组。但是当我尝试将它们包含在
中时,它仍然会运行每个测试。Maven代码一点也不奇怪:

<profile>
    <id>smoke-tests</id>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <parallel>classes</parallel>
                    <threadCount>4</threadCount>
                    <perCoreThreadCount>false</perCoreThreadCount>
                    <!-- <excludeGroups>de.package.SmokeTest</excludeGroups> -->
                    <groups>de.package.SmokeTest</groups>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

烟雾测试
假的
org.apache.maven.plugins
maven故障保护插件
2.12
班级
4.
假的
包装烟度试验
集成测试
验证
当然,我可以通过使用
来解决这个问题,但我确实希望使用
@Category
注释


感谢您的帮助

这是一个在2.12.1中修复的错误:。如果无法升级,请显式指定junit提供程序,它应该可以工作:

<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.12</version>
  <configuration>
    <groups>uk.co.farwell.test.SlowTests</groups>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.surefire</groupId>
      <artifactId>surefire-junit47</artifactId>
      <version>2.12</version>
    </dependency>
  </dependencies>
</plugin>

maven surefire插件
2.12
uk.co.farwell.test.SlowTests
org.apache.maven.surefire
surefire-junit47
2.12

谢谢您的回答。我用
mvn测试尝试了您的解决方案,Maven没有运行任何测试。它只显示
测试运行:0、失败:0、错误:0、跳过:0
您尝试了哪种解决方案?升级到2.12.1或添加依赖项?抱歉,我刚刚注意到您启用了并行运行。看看,这可能会有影响。试试2.12.3。