ANT教程之十五 Ant Junit集成

JUnit 是基于Java常用的单元测试框架进行开发。它是易于使用和易于延伸。有许多JUnit扩展可用。如果你不熟悉Junit的,你应该从www.junit.org下载JUnit和阅读JUnit的使用手册。

本教程讨论了关于执行使用Ant 的JUnit测试。Ant 通过这个简单Junit 的任务变得简单。

以下展示的是JUnit 任务的属性。

Properties 描述
dir Where to invoke the VM from. This is ignored when fork is disabled.
jvm Command used to invoke the JVM. This is ignored when fork is disabled.
fork Runs the test in a separate JVM
errorproperty The name of the property to set if there is a Junit error
failureproperty The name of the property to set if there is a Junit failure
haltonerror Stops execution when a test error occurs
haltonfailure Stops execution when a failure occurs
printsummary Advices Ant to display simple statistics for each test
showoutput Adivces Ant tosend the output to its logs and formatters
tempdir Path to the temporary file that Ant will use
timeout Exits the tests that take longer to run than this setting (in milliseconds).

让我们继续的Hello World fax web应用程序的主题,并添加一个JUnit目标。

下面的例子展示了一个简单的JUnit测试执行

<target name="unittest">
  <junit haltonfailure="true" printsummary="true">
    <test name="com.yiibai.UtilsTest"/>
  </junit>
</target>

上面的例子显示的Junit对com.yiibai.UtilsTest JUnit类执行。运行上面会产生下面的输出

test:
[echo] Testing the application
[junit] Running com.yiibai.UtilsTest
[junit] Tests run: 12, Failures: 0, Errors: 0, Time elapsed: 16.2 sec
BUILD PASSED

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值