使用Maven命令运行Junit Suite [英] Run Junit Suite using Maven Command

查看:126
本文介绍了使用Maven命令运行Junit Suite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个Junit测试套件(SlowTestSuite,FastTestSuite等).我只想使用maven命令运行特定的套件.例如

I have multiple Junit test suites (SlowTestSuite, FastTestSuite etc). I would like to run only specific suite using maven command. e.g.

mvn clean install test -Dtest=FastTestSuite -DfailIfNoTests=false

,但不起作用.只是根本不运行任何测试.请提出任何建议.

but its not working. Just not running any test at all. Any suggestions please.

推荐答案

我已经通过将属性添加到pom中来实现了这一点:

I have achieved this by adding property into pom as:

<properties>
    <runSuite>**/FastTestSuite.class</runSuite>
</properties>

和maven-surefire-plugin应该为:

and maven-surefire-plugin should be:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <includes>
                    <include>${runSuite}</include>
                </includes>
            </configuration>
        </plugin>

,因此默认情况下它将运行FastTestSuite,但您可以运行其他测试,例如使用Maven命令将SlowTestSuite用作:

so it means by default it will run FastTestSuite but you can run other test e.g. SlowTestSuite using maven command as:

mvn install -DrunSuite=**/SlowTestSuite.class -DfailIfNoTests=false

这篇关于使用Maven命令运行Junit Suite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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