软件测试(Software Testing)Lab1: Junit

1. Install JUnit, Hamcrest, eclemma.

  I use IntelliJ IDEA IDE instead of Eclipse. Now I report the step to install the JUnit in IDEA. First of all, we should download the jar package from the website, we choose the junit-4.12.jar. After we create a new project, we click “file” menu, choose the “project structure”, and then, we choose “Modules” at the left menu, select “Dependencies” at the right menu, after that we click “<Module source>” and click “+” to add the junit-4.12.jar into project.

  The same way, we can easily add the hamcrest-all-1.3.jar add into project.

  We don’t need add the eclemma into the IDEA, because IDEA have a selection is “Run with Coverage”. On the other hand, we can’t add eclemma into IDEA, because it is a plugin for Eclipse IDE.

  More details in the following picture.

 

2. result

  This is the structure of my project.

  This is my code to judge a triangle.

  This is my test class.

  After we run the test, we can get like the following result.

  Then we can get the coverage after “run with the coverage”.

  The green besides the line number means this line is been covered.

 

posted @ 2017-03-12 16:30  喷水小火龙  阅读(212)  评论(0编辑  收藏  举报