码迷,mamicode.com
首页 > 其他好文 > 详细

Junit 单元测试

时间:2017-02-21 00:52:55      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:ext   jar   java   nbsp   class   location   ons   test   用例   

1.Junit 官方地址  http://www.junit.org/

2.Junit 4 在Junit 3 基础上有了较大的改进,这里采用Junit 4 测试,之前 需要确保将Junit.jar 加入Build Path中.

3.Eclipse 一步一步深入:

  File -> New -> Other ->Java -> JUnit -> JUnit Test Case ,创建某个类的测试类  一般以Test 结尾.

4.下面测试Spring框架  

  需要在类下面加上@RunWith(SpringJUnit4ClassLoader.class)    //基于Junit 4 的Spring测试矿建

            @ContextConfiguration(locations={"/applicationContext.xml"})   启动Spring框架

    在待测试方法上面加注解@Test

    Run As ->  JUnit Test 运行该测试用例检查业务类方法的正确性

 

Junit 单元测试

标签:ext   jar   java   nbsp   class   location   ons   test   用例   

原文地址:http://www.cnblogs.com/QQ931697811/p/6422099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!