【软件测试】1st Experiment: Junit, Hamcrest and Eclemma
1. Experiment Purposes
- Install Junit(4.12), Hamcrest(1.3) with Eclipse
- Install Eclemma with Eclipse
- Write a java program for the triangle problem and test the program with Junit.
2. Experiment Procedure
- Install the junit and hamcrest: Upload the 'junit-4.12.jar' and the 'hamcrest-all-1.3.jar' and add them to the new project 'TriangleTest';
- Install the EclemmaIn Eclipse: Help -> Install New Software -> add thr url and the name -> finished;
- Create the main class to judge wheater it can be a triangle(equilateral,isosceles,scalene) composed by given 3 number(a,b,c);
- Create a test class to do the testing, try the '@test, @BeforeClass, @AfterClass, @Before and @After';
- Try the coverage.
3. Experiment Results
- Test some annotations
the source code:
the console output:
2. 4 test cases were used in the test class:(2,2,2), (2,2,1), (4,3,2), (0,3,2), and the result is :
3. Coverage
in the Triangle.java:
in the TestTriangle.java: