Eighth assignment: 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 (a,b,c) Test Prophecy (Oracle: Right angle, isosceles, equilateral triangle)
Input (2,2,2) Equilateral triangle
Input (2,0,2) Not a triangle.
Input (2,3,2) Isosceles Triangle
Input (2,3,3) Not equilateral triangle.
Input (3,4,5) Right 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 push the source code to your own github.

1 Import Staticorg.junit.assert.*;2  3     Importorg.junit.Test;4  5      Public classtesttriangle{6  7 @Test8          Public voidTestIsTriangle1 () {9Triangle T =NewTriangle (2,2,2);TenAssertequals (T.gettype (t), "Regular"); One         } A       - @Test -          Public voidTestlsTringle1 () { theTriangle1 t=NewTriangle1 (2,0,2); - Assertfalse (T.istriangle1 (t)); -         }  -       + @Test -          Public voidTestIsTriangle3 () { +Triangle T =NewTriangle (2,3,2); AAssertequals (T.gettype (t), "Isoceles"); at         } - @Test -          Public voidTestIsTriangle2 () { -Triangle T =NewTriangle (2,3,3); -Assertequals (T.gettype (t), "Scalene"); -         } in  - @Test to          Public voidtestIsTriangle5 () { +Triangle T =NewTriangle (3,4,5); -Assertequals (T.gettype (t), "Zhijiao"); the         } *  $}

Test results:

[ must do title 3] experience. Write down the knowledge you learned from this practice.

Determine if the difference is greater than the third side of the data

To test the script steps:

Write well not triangles, isosceles, equilateral, right angles, not equilateral test scripts

Judge the type of triangle, equilateral isosceles, not a triangle, not equilateral triangle, right triangle. Initially learned the JUnit test.

Eighth assignment: 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.