有没有办法告诉surefire跳过特定程序包中的测试? [英] Is there a way to tell surefire to skip tests in a certain package?

查看:86
本文介绍了有没有办法告诉surefire跳过特定程序包中的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于以下内容.

我想要一种在surefire中跳过dao测试的方法.试图避免定义套件的开销.

I would like a way to skip my dao tests in surefire. Trying to avoid overhead of defining Suites.

借助CI,我希望每晚进行一次运行所有测试,并进行一次仅对快速"测试进行SCM的5分钟轮询.

With CI I'd like to have one nightly that runs all tests and another 5 minute poll of SCM that runs only 'fast' tests.

mvn -DskipPattern=**.dao.** test

推荐答案

让我扩展Sean的答案.这是您在pom.xml中设置的:

Let me extend Sean's answer. This is what you set in pom.xml:

<properties>
  <exclude.tests>nothing-to-exclude</exclude.tests>
</properties>
<profiles>
  <profile>
    <id>fast</id>
    <properties>
      <exclude.tests>**/*Dao*.java</exclude.tests>
    </properties>
  </profile>
</profiles>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <excludes>
     <exclude>${exclude.tests}</exclude>
    </excludes>
  </configuration>
</plugin>

然后在CI中像这样启动它们:

Then in CI you start them like this:

mvn -Pfast test

就是这样.

这篇关于有没有办法告诉surefire跳过特定程序包中的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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