"Software Testing" course Experiment 3 the second question

Source: Internet
Author: User

2. Application of Logic overlay

According to the program flowchart given, write out the statement overlay, branch coverage of the test case, and the path it covers

Add-on: According to the program flowchart, write code (define a class and method to implement), generate unit tests with JUnit, and test using the test cases previously designed

language sentence Overlay : A E G test Case: X = 4 Y = 0

A E F test Case: X = 5 Y = 0

a b c test Case: X = 3 Y = 2

Branch Coverage: A E G test Case: X = 4 Y = 0

A E F test Case: X = 5 Y = 0

a b d test Case: X = 3 Y = 0

a b c test Case: X = 4 Y = 2

Additional questions:

Code:

Package com.xxxx;

import Java.util.Scanner;

import org.junit.Test;

Public class Locgic {

@Test

Public void cover () {

System. out. Print ("Please enter the value of x:");

Scanner in = new Scanner (System. in);

int X = In.nextint ();

System. out. Print ("Please enter the value of y:");

int Y = In.nextint ();

if (x<4| | y>0) {

if (y>1) {

y=y+1;

System. out. println (X);

System. out. println (Y);

}Else{

System. out. println (X);

System. out. println (Y);

}

}Else{

if (y>=5) {

X=x-y;

System. out. println (X);

System. out. println (Y);

}Else{

X=x+y;

System. out. println (X);

System. out. println (Y);

}

}

}

}

Import the junit-4.4 test class and enter all of the above test cases to test successfully.

"Software Testing" course Experiment 3 the second question

Related Article

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.