A preliminary study on ST Lab1--junit and coverage test

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.