如何使用maven-surefire-plugin在同一项目中执行JUnit和TestNG测试? [英] How to execute JUnit and TestNG tests in same project using maven-surefire-plugin?

查看:597
本文介绍了如何使用maven-surefire-plugin在同一项目中执行JUnit和TestNG测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我同时拥有两种类型的测试,但是当我说"mvn test"时,它仅执行TestNG测试,而不执行Junit.我要一个接一个地执行.有任何想法吗?

Right now I have both type of tests but when I say "mvn test" it only executes TestNG tests and not Junit. I want to execute both one after another. Any Idea ?

推荐答案

有一个尚待解决的问题 s,所以没有优雅的方法可以做到这一点.

There is an open issue for this, so there's no elegant way to do this.

选择一个框架并坚持下去会容易得多.

It would be far simpler for you to pick a framework and stick with it.

我的上一个答案不起作用,因为您不能在执行中指定依赖项. 我已经尝试了几种方法,但是我能管理的最好方法是为TestNG依赖关系创建一个配置文件,以便您可以在TestNG和JUnit测试之间切换,似乎没有办法同时运行TestNG和Junit 4测试

My previous answer doesn't work because you can't specify dependencies in the execution. I've tried a few approaches, but the best I can manage is to create a profile for the TestNG dependency so you can toggle between TestNG and JUnit testing, there doesn't seem to be a means to run both TestNG and Junit 4 tests.

要注意的另一点:您可以从TestNG启动JUnit测试 ,但我认为这仅适用于JUnit 3测试.

One other point to note: You can launch your JUnit tests from TestNG, but I think this only works for JUnit 3 tests.

这篇关于如何使用maven-surefire-plugin在同一项目中执行JUnit和TestNG测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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