Individual exercises-unit test exercises

Source: Internet
Author: User

Goals and Requirements

    • Unit Test Training (JUnit framework app)

    • Design method of test case

Requirements:

    • [ 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. (10 points)
Test Cases
Serial number Test input: Three edges (a,b,c) Test Prophecy (Oracle: Right angle, isosceles, equilateral triangle)
1 Input (1,1,1) Equilateral triangle
2 Input (* * *) ***
    • [ 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)

    • [ 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)

Detailed content

    • [ 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.
Serial number Test input: Three edges (a,b,c) Test Prophecy (Oracle: Right angle, isosceles, equilateral triangle)
1 (1,1,1) Equilateral triangle
2 (5,6,5) Isosceles Triangle
3 ( -1,3,5) Illegal triangles
4 (5,5,15) Illegal triangles
5 ( -7,-7,10) Illegal triangles
6 ( -8,-5,-4) Illegal triangles
    • [ 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.
Import Static org.junit.assert.*;    Import  org.junit.Test; public class  testtriangle{@Test public void  TestIsTriangle1 () {Triangle t = new Tria            Ngle (1,1,1 ); Assertfalse (T.istriangle (t)); } @Test public void  TestIsTriangle2 () {//According to the mutant, this Test case should fail Tria Ngle t = new Triangle (5,6,5 ), Assertfalse (T.istriangle (t)), @Test public void  TestIsTriangle3 () {Triangle T = new Triangle ( -1,3,5 ); Assertfalse (T.istriangle (t));} @Test public void  testIsTriangle4 () {Triangle t = new Triangle (5,5,15 ), Assertfalse (T.istriangle (t)), @Test public void  testIsTriangle5 () {Triangle t = new Triangle ( -7,-7,10 ), Assertfalse (T.istriangle (t)), @Test public void  TestIsTriangle6 () {Triangle t = new Triangle ( -8,-5,-4 ); Assertfalse (T.istriangle (t));          
    • [ must do title 3] experience. Write down the points of knowledge you have gained from this practice.

In designing test cases, equivalence partitioning can be divided into four categories: non-triangular, general triangular, isosceles triangle, and equilateral triangle. When designing test data, be aware of some special data testing. Data Basic determination process: whether the edge length is within the value range, the third side is less than the sum of the two sides is greater than the difference between, whether it is equilateral isosceles. and learned how to use JUnit.

Individual exercises-unit test exercises

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.