为什么< excludeGroups>工作,但< groups>不? [英] Why does <excludeGroups> work but <groups> doesnt?

查看:108
本文介绍了为什么< excludeGroups>工作,但< groups>不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用@Category-JUnit和配置文件的注释来拆分集成测试和冒烟测试.这样,如果我运行mvn clean install -P smoke-tests,则仅执行Smoke-Tests,而如果我运行mvn clean install,则每个测试都将运行.

I am trying to split up integration-tests and smoke-tests using the @Category - Annotation of JUnit and profiles. So that if I run mvn clean install -P smoke-tests only the Smoke-Tests get executed and if I run mvn clean install every test runs.

问题是:

当我用<excludeGroups>排除Maven中的组时,它按预期排除了这些组.但是,当我尝试将它们包含在<groups>中时,它仍然会运行每个测试. Maven代码没什么花哨的:

When I exclude the groups in Maven with <excludeGroups> it excludes the groups as expected. But when I try to include them with <groups> it still runs every test. The Maven code is nothing fancy:

<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>

我当然可以使用<include><exclude>解决此问题,但是我真的很想使用@Category注释.

Of course I could solve this problem by using <include> and <exclude> but I would really like to use the @Category Annotation.

感谢您的帮助.

推荐答案

此错误已在2.12.1中修复: JUnit类别仅在显式设置了junit47 provider的情况下起作用.如果您无法升级,请明确指定一个junit提供者,它应该可以工作:

This is a bug which is fixed in 2.12.1: JUnit categories only work when junit47 provider is explicitly set. If you can't upgrade, explicitly specify a junit provider, and it should work:

<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>

这篇关于为什么&lt; excludeGroups&gt;工作,但&lt; groups&gt;不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆