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