使用Maven2进行单元测试

使用Maven2进行单元测试

转载:http://hi.baidu.com/mylovechangchu/blog/item/a32b82dd80640feb76c638fc.html

2008年02月26日 星期二 10:21

Now let's test the application. A few simple test classes can be found in the source code. Unit testing is (or should be!) an important part of any enterprise Java application. Maven completely integrates unit testing into the development lifecycle. To run all your unit tests, you invoke the test lifecycle phase:

现在来测试应用程序,在源代码中可以找到一些简单测试类。单元测试是(或者应该是)任何企业java应用程序的重要组成部分。Maven将单元测试完全集成进了开发生命周期。要运行所有的单元测试,可以调用test生命周期阶段:

mvn test

If you want to run only one test, you can use the test parameter:

如果你只想运行某个单元测试,可以使用test参数指定:

mvn test -Dtest=HotelModelTest

A nice feature of Maven 2 is its use of regular expressions and the test parameter to control the tests you want to run. If you want to run only one test, you just indicate the name of the test class:

Maven 2的一个特性是test参数使用规则表达式来运行测试,如果只想运行某个测试,你只要指出测试类的名称就可以了:

mvn test -Dtest=HotelModelTest

If you want to run only a subset of the unit tests, you can use a standard regular expression. For example, to test all ModelTest classes:

如果你想运行一组单元测试,可以使用标准的规则表达式,比如,为了测试所有的ModelTest类:

mvn test -Dtest=*ModelTest
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值