如何导出(JUnit)测试套件作为可执行jar [英] how to export (JUnit) test suite as executable jar
本文介绍了如何导出(JUnit)测试套件作为可执行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何从具有主类的项目中生成可运行的jar,但是我对于如何添加一个
TestRunner
而无能为力。是否有一个简单的方法,或者我必须做一个解决方法的主类调用
TestRunner
不知何故? 解决方案
你是正确的,一个main()方法需要一个可执行文件jar。
很容易将一个主要方法添加到测试套件。
public static void main(String [] args)throws Exception {
JUnitCore.main(
com.stackoverflow.MyTestSuite);
}
Is there a way in eclipse (Helios) to package/export my JUnit test suites (or maybe even test cases if possible) as executable jars?
I know how to generate runnable jars from projects with a main class, but i'm clueless about how to include a TestRunner
.
Is there a straightforward way, or do I have to make a workaround main class calling the TestRunner
somehow?
Details would be great.
解决方案
You are correct that a main() method is needed for an executable jar.
It's easy to add a main method to your test suite though.
public static void main(String[] args) throws Exception {
JUnitCore.main(
"com.stackoverflow.MyTestSuite");
}
这篇关于如何导出(JUnit)测试套件作为可执行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文