📅  最后修改于: 2020-11-18 07:57:14             🧑  作者: Mango
JUnit是用于基于Java的开发的常用单元测试框架。它易于使用且易于扩展。有许多可用的JUnit扩展。如果您不熟悉JUnit,则应该从www.junit.org下载它并阅读其手册。
本章介绍如何使用Ant执行JUnit测试。 Ant使它直接完成了JUnit任务。
JUnit任务的属性如下所示-
Sr.No. | Properties & Description |
---|---|
1 |
dir Where to invoke the VM from. This is ignored when fork is disabled. |
2 |
jvm Command used to invoke the JVM. This is ignored when fork is disabled. |
3 |
fork Runs the test in a separate JVM |
4 |
errorproperty The name of the property to set if there is a JUnit error |
5 |
failureproperty The name of the property to set if there is a JUnit failure |
6 |
haltonerror Stops execution when a test error occurs |
7 |
haltonfailure Stops execution when a failure occurs |
8 |
printsummary Advises Ant to display simple statistics for each test |
9 |
showoutput Advises Ant to send the output to its logs and formatters |
10 |
tempdir Path to the temporary file that Ant will use |
11 |
timeout Exits the tests that take longer to run than this setting (in milliseconds). |
让我们继续Hello World Fax Web应用程序的主题,并添加一个JUnit目标。
以下示例显示了一个简单的JUnit测试执行-
本示例显示com.tutorialspoint.UtilsTest junit类上JUnit的执行。运行上面的代码将产生以下输出-
test:
[echo] Testing the application
[junit] Running com.tutorialspoint.UtilsTest
[junit] Tests run: 12, Failures: 0, Errors: 0, Time elapsed: 16.2 sec
BUILD PASSED