如何将 (JUnit) 测试套件导出为可执行 jar [英] how to export (JUnit) test suite as executable jar

查看:48
本文介绍了如何将 (JUnit) 测试套件导出为可执行 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 eclipse (Helios) 中有没有办法将我的 JUnit 测试套件(或者甚至是测试用例)打包/导出为可执行的 jar 包?

我知道如何从具有主类的项目生成可运行的 jar,但我对如何包含 TestRunner 一无所知.
有没有直接的方法,或者做我必须以某种方式创建一个调用 TestRunner 的解决方法主类?

细节会很棒.

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.

推荐答案

您说的对,可执行 jar 需要 main() 方法.

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屋!

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