Job 8: Unit Test exercise

Source: Internet
Author: User

[ must do 1] for the triangle given in Appendix 1 to Judge Java code, the use of equivalent class partitioning method to design test cases, tabular form of the design of the test cases, written to the blog.

Test Cases
Serial number Test input: Three edges Test prophecy
1 3, 4, 5   Triangle
2 5, 5, 5 Equilateral triangle
3 3, 5, 3 Isosceles Triangle
4 1, 2, 7 Not a triangle.

[ must do 2] imitate Appendix 2 gives the triangle judgment junit test Code, Design Unit test script, test [ must do 1] design of the test case. Note the order in which the test cases appear in the test script is consistent with the order listed in the [ required title 1] table. Run the resulting test script, truncate the result graph, write to the blog, and commit the source code to your own github. (20 points)

Import Staticorg.junit.assert.*; Importorg.junit.Test;  Public classtesttriangle{@Test Public voidTestIsTriangle1 () {Triangle T=NewTriangle (3,4,5); Assertequals (T.gettype (t),"Scalene"); } @Test Public voidTestIsTriangle2 () {//according to the mutant, this test case should failTriangle T =NewTriangle (5,5,5); Assertequals (T.gettype (t),"Regular"); } @Test Public voidTestIsTriangle3 () {Triangle T=NewTriangle (3,5,3); Assertequals (T.gettype (t),"Isoceles"); } @Test Public voidtestIsTriangle4 () {Triangle T=NewTriangle (1,2,7); Assertequals (T.gettype (t),"Illegal"); }    }     

The test results are all in line with expectations.

[ must do title 3] experience. Write down the Knowledge points (PS: Test Case design methods and steps; test script design steps or main content) that you gain from this exercise. (10 points)

First, create a new JUnit test file below the Java project, and then write the code in appendix two. Create a new class in the sub-directory, write the judgment code in appendix one, and change the value of the triangle three sides,

As well as the desired results of the test, you can reach the test. If you need to change the direction of the test, simply add the new judging criteria and expected values in class.

Job 8: Unit Test exercise

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.