📜  Apache Ant JUnit任务

📅  最后修改于: 2020-12-26 14:07:20             🧑  作者: Mango

Apache Ant JUnit任务

此任务用于从JUnit测试框架运行测试。此任务取决于默认情况下未包含在Apache Ant分发中的外部库。

运行此任务都需要junit.jar和ant.junit.jar ,因此请将这些JAR放在ANT_HOME / lib位置。

build.xml文件中使用元素来实现此任务。它还支持嵌套元素 ,该元素表示类似路径的结构。

Apache Ant Junit任务属性

Attribute Description Required
printsummary It prints summery of the test cases. No
fork Run the tests in a separate JVM No
forkmode It controls how many JVMs get created if we want to fork test cases. No
haltonerror It stops the build process if any error occurs. No
errorproperty This property is set in error event. No
haltonfailure It stops the build process if a test fails. No
timeout It cancels the individual tests if they don’t finish in the given time. No
maxmemory Maximum amount of memory to allocate to the forked JVM. No
jvm The command used to invoke JVM. No
dir The directory in which to invoke JVM. No
tempdirA directory where Ant should place temporary files.No reloadingWhether or not a new classloader should be instantiated for each test case.No clonevmIt makes a clone of the process running in JVM.No

让我们看一些示例,以了解此测试任务的功能。

Apache Ant JUnit任务示例

    
    
        
                
        
    

上面的示例正在运行一个定义在TestCase中的测试用例。

本示例运行一个单独的JVM并对其进行测试。 fork属性将运行一个新的JVM。