Junit hamcrest and eclemma 的安装

junit: 用Eclipse安装junit安装其实很简单,就是在项目中倒入两个包就可以,但是我想用maven来在eclipse中建立项目,但是可能是eclipse的版本太低所以不能使用junit4,所以我选择了使用IDEA来做,首先就是用IDEA中maven来建立项目,并且在pom.xml文件中  加入junit 的包依赖: <dependency>
                             <groupId>junit</groupId>
                             <artifactId>junit</artifactId>
                               <version>4.12</version>
                           <scope>test</scope>
                            </dependency>

这样就直接安装好了junit。

hamcrest的安转就更简单了,直接在使用的类文件加上import static org.hamcrest.Matchers.*;就可以使用了

IDEA的覆盖测试呢不需要eclemma安装,直接在EDIT configuration中添加就可以。

用边长度分别为(1,1,1)  (1,1,0)  (2,3,4)进行测试,测试结果都通过,并且覆盖率达到100%

 

posted @ 2016-05-08 12:45  王狗蛋  阅读(161)  评论(0编辑  收藏  举报