简体   繁体   English

如何将(JUnit)测试套件导出为可执行jar

[英]how to export (JUnit) test suite as executable jar

Is there a way in eclipse (Helios) to package/export my JUnit test suites (or maybe even test cases if possible) as executable jars? 在eclipse(Helios)中是否有办法将我的JUnit测试套件(或者甚至可能的测试用例)打包/导出为可执行的jar?

I know how to generate runnable jars from projects with a main class, but i'm clueless about how to include a TestRunner . 我知道如何从具有主类的项目生成可运行的jar,但我对如何包含TestRunner一无所知。
Is there a straightforward way, or do I have to make a workaround main class calling the TestRunner somehow? 是否有一种直截了当的方式,或者我是否必须以某种方式制作一个解决方法主类来调用TestRunner

Details would be great. 细节会很棒。

You are correct that a main() method is needed for an executable jar. 你是正确的,可执行jar需要一个main()方法。

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");            
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM