如何在Maven的集成测试目标中运行单个测试 [英] How to run individual test in the integration-test target in maven

查看:107
本文介绍了如何在Maven的集成测试目标中运行单个测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.

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

What I want to do is run just one test in the integration-test. I tried doing :

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

但这不起作用. -Dtest仅运行单元测试目标中的测试,而不运行集成测试阶段.我改用-Dintegration-test=<my-test>,但被忽略了.

but that does not work. The -Dtest runs only the tests in the unit test goal, not the integration-test phase. I tried the -Dintegration-test=<my-test> instead, and that was ignored.

有没有办法做到这一点?

Is there a way to do that ?

我的配置是:

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

推荐答案

如果您使用的是

If you're using the Maven failsafe plugin, you can run a single integration test by setting the it.test property to your fully qualified test class name:

mvn -Dit.test=your.TestCase verify

有关详细信息,请参见故障安全插件文档 a>.

See the failsafe plugin docs for more info.

这篇关于如何在Maven的集成测试目标中运行单个测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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