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

查看:24
本文介绍了使用 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 但您可以运行其他测试,例如SlowTestSuite 使用 maven 命令作为:

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天全站免登陆