Software Testing Technology Experiment 2 Boundary Value Analysis Method Experiment

Experiment 2 Boundary Value Analysis Experiment

1. Experimental purpose

1. Use Eclipse to build the test environment.

2. Master boundary value analysis method to design test cases.

2. Experimental content

1. Read the description of the triangle problem carefully, correct the source code errors given in the guide, and compile the correct source code under test and record it as follows:

Correct procedure for triangle problems:

import java.util.Scanner;

public class Rjcs {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the value of a");
int a = sc.nextInt();
System.out.println("Please enter the value of b");
int b = sc.nextInt();
System.out.println("Please enter the value of c");
int c = sc.nextInt();
if(a>=1 & amp; & amp;a<=200) {
if(b>=1 & amp; & amp; b<=200) {
if(c>=1 & amp; & amp;c<=200) {
test(a,b,c);
}else {
System.out.println("The value of c is illegal!");
}
}else {
System.out.println("The value of b is illegal!");
}
}else {
System.out.println("The value of a is illegal!");
}
}
//Determine triangle type
public static void test(int a,int b,int c){
boolean pd = false;
if((a + b>c) & amp; & amp;(a + c>b) & amp; & amp;(b + c>a)){
if((a==b) & amp; & amp;(b==c)) {
System.out.println("Equilateral Triangle");
}else if((a==b)||(b==c)||(a==c)) {
System.out.println("Isosceles Triangle");
}else {
System.out.println("General triangle");
}
}else {
System.out.println("Cannot form a triangle");
}
}
}

2. Use boundary value analysis method to design test cases. The analysis is as follows:

The value ranges of the three sides a, b, and c are 1≤a≤100, 1≤b≤100, 1≤c≤100; respectively. Therefore, the boundary values of the three sides can be taken as side a: 0,1,2,99,100,101, side b: 0,1,2,99,100,101, side c: 0,1,2,99,100,101.

3. Selection of boundary points and selection of test data.

Table 2-1 Triangle problem boundary points and corresponding test data

Enter conditions

Boundary value

Test Data

Side length a

1,100

0,1,2,99,100,101

Side length b

1,100

0,1,2,99,100,101

Side length c

1,100

0,1,2,99,100,101

4. Test case design

Table 2-2 Boundary value test cases for triangle problems

test case

serial number

Input data

expected output

A/B/C/x is not compliant

Test Results

A/B/C/x is not compliant

defect

Y/N

a

b

c

1

0

3

4

aIllegal

a does not comply with regulations

N

2

1

3

4

D

D

N

3

2

3

4

C

C

N

4

99

98

97

C

C

N

5

100

98

97

C

C

N

6

101

98

97

aIllegal

aIllegal

N

7

10

0

11

bIllegal

bIllegal

N

8

10

1

11

D

D

N

9

10

2

11

C

C

N

10

98

99

97

C

C

N

11

98

100

97

C

C

N

12

98

101

97

bIllegal

bIllegal

N

13

12

11

0

cIllegal

cIllegal

N

14

12

11

1

D

D

N

15

12

11

2

C

C

N

16

98

97

99

C

C

N

17

98

97

100

C

C

N

18

98

97

101

cIllegal

cIllegal

N

3. Experiment summary

Through this experiment, I learned about the boundary value analysis method in black box testing. Mastered the boundary value analysis method and how to write boundary value test cases, and how to determine and test boundary values. The experiment can be completed successfully!