Experiment Name:
The first experiment of software testing
Experimental Purpose:
Learn about the use of junit,hamcrest,eclemma these Intelij idea plugins or development packages
Experimental content:
Write a Java program to determine whether a given triangular triangle is equilateral triangle, isosceles triangle, or non-equilateral triangle, and uses Junit,hamcrest,eclemma for functional testing and coverage testing.
Experimental steps:
1) Download the corresponding software development kit for Junit,hamcrest,eclemma
I'm using Junit-4.12.jar and Hamcrest-all-1.3.jar here.
2) Install the JUnit plug-in for idea (usually comes with your own).
3) write the Triangle Judgment program.
Create a new Java project and write a triangle judgment program.
4) Writing test samples
importing JUnit development packages;
To create a new module, the test sample should have the same hierarchical relationship as the source code;
Add module dependencies (so that you can write tests in the corresponding package without importing the package of the source program, and the structure is clear)
Right click on the project, select "Open mudule Settings"-"module", select "Test" module (new module), click on the right "+" sign, select modules dependency
Write a test sample (detailed on GitHub source code)
5) Run for functional testing and coverage testing
Right-click the code and note that the run with coverage must be right-running a package and cannot be a single file.
Experimental results:
A preliminary study on ST Lab1--junit and coverage test