junit测试套件 [英] junit test suites

查看:90
本文介绍了junit测试套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本(test.bat),该脚本允许我通过命令行启动一个Java测试: -java -cp()org.junit.runner.JUnitCore包.Class

I have a script(test.bat) that allows me to launch one java test by command line : -java -cp() org.junit.runner.JUnitCore package.Class

现在我想对几个Java测试做同样的事情吗? 我该怎么办?我是否必须为每个Java测试添加字节码? 请给我一个例子吗?

Now I want to do the same for several java tests ? how could I do it? should I have to add the byte code for each java test? could I have an example , please?

推荐答案

您可以使用Ant使用junit ant任务通过单个命令运行测试.这是一个有关如何使用它的示例:

You can use Ant to run your tests with a single command with the junit ant task. Here's an example on how to use it:

<target name="runtests" depends="clean,compiletests">           
    <junit printsummary="yes" haltonfailure="no">
        <classpath>
            <path refid="test.classpath" />                 
            <pathelement location="${test.classes}"/>
        </classpath>                                
        <formatter type="xml"/>     
        <batchtest fork="yes" todir="${test.reports}">
            <fileset dir="${test.src}">
                <include name="**/*Test*.java"/>
            </fileset>
        </batchtest>
    </junit>        
</target>

该目标使用batchtest,这是junit ant任务的一部分.它设置了您的测试类路径,因此将包括所有在类名中包含 Test .java模式的测试.查看 JUnit任务文档.

That target uses batchtest which is part of the junit ant task. It sets your test classpath so all your tests that contain the Test.java pattern in their class name will be included. Check out the JUnit Task documentation.

这篇关于junit测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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