maven-2 - 如何在 Maven 的集成测试目标中运行单个测试

标签 maven-2 integration-testing maven-surefire-plugin

我们在 maven 中为我们的集成测试阶段生命周期定义了数百个测试,它们需要很长时间才能完成。

我想要做的只是在 integration-test 中运行一个测试.我试着做:

mvn -Dtest=<my-test> integration-test

但这不起作用。 -Dtest只运行单元测试目标中的测试,而不是集成测试阶段。我试过 -Dintegration-test=<my-test>相反,这被忽略了。

有没有办法做到这一点 ?

我的配置是:
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <executions> 
        <execution> 
            <id>surefire-it</id> 
            <phase>integration-test</phase> 
            <goals> 
                <goal>test</goal> 
            </goals> 
            <configuration> 
                <excludes> 
                    <exclude>none</exclude> 
                </excludes> 
                <includes>
                    <include>**/api/**</include> 
                </includes> 
    ..... 

最佳答案

如果您使用的是 Maven failsafe plugin ,您可以通过设置 it.test 来运行单个集成测试您的完全限定测试类名称的属性:

mvn -Dit.test=your.TestCase verify

the failsafe plugin docs for more info .

关于maven-2 - 如何在 Maven 的集成测试目标中运行单个测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/894737/

相关文章:

Java:如何构建基于 Maven 的项目的独立发行版?

python - 如何正确地对网络应用程序进行单元测试?

maven - 无法从 Maven 测试单元中调用 sun.security.tools.keytool.Main

java - 如何以编程方式获取依赖项的 SCM 连接 URL?

java - 为什么我创建一个新域不存在主密码

unit-testing - 如何让 maven 在激活非默认配置文件的情况下运行单个测试类?

selenium - 使用带有 127.0.0.1 的内容脚本和带有 Firefox 插件的自定义端口

spring-mvc - 如何对 Spring Controller Advice 进行集成测试

maven - 使用 Spock 和 Maven 在单个测试类中运行特定测试

maven - Jenkins 管道构建错误 -> 未找到测试报告文件