如何控制Maven中测试的执行顺序? [英] How do I control the order of execution of tests in Maven?

查看:181
本文介绍了如何控制Maven中测试的执行顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按顺序运行测试.我在任何地方都找不到足够的文献资料.我宁愿从命令行执行此操作.像

I need to run tests in order. I fail to find this adequately documented anywhere. I would prefer to do this from command line. Something like

 mvn -Dtest=test1,test2,test3,test5 test

我该怎么做?

推荐答案

您无法指定测试的运行顺序.

You can't specify the run order of your tests.

一种解决方法是设置 runOrder参数到字母顺序.

A workaround to do this is to set the runOrder parameter to alphabetical.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <runOrder>alphabetical</runOrder>
    </configuration>
</plugin>

然后您需要重命名测试以获得预期的顺序.

and then you need to have rename your tests to obtain the expected order.

但是,进行依赖测试并不是一个好主意.单元测试必须第一.

However it isn't a good idea to have dependent tests. Unit tests must be fIrst.

这篇关于如何控制Maven中测试的执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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