Download presentation
Presentation is loading. Please wait.
1
Software Testing Structural testing 1
2
Triangle Example cin >> a >> b >> c ;
type = “scalene”; if (a == b || a == c || b == c) type= “isoscoles”; if (a == b && a == c) type = “equilateral”; if (a >= b+c || b >= a+c || c >= a+b) type=“not a triangle”; if (a <= 0 || b <= 0 || c <= 0) type=“bad input”; cout<< type;
3
Control Flow Graph TTYP1 – what are the paths through this code?
4
A Model of Testing - Mappings
a program maps elements of the domain to elements of the range the specification also specifies a mapping of the domain to the range correctness is that the program is the same mapping as the specification 9
5
Domains in testing 12
6
Subdomain – typical definition
A subdomain is a set of input points (data points, tests, etc) that are treated identically by the program (or almost identically). That is, they usually take the same path through the program and the same operations are applied to the values. Subdomains are normally mutually exclusive
7
TTYP 2 What is a set test cases for the “path” subdomains for the triangle code?
8
Typical Structural Coverage
C0 – every statement C1 – every branch
9
Recommended use of C0 and C1
Select good test cases independent of coverage If Cx is not achieved, continue to select specific, but good test cases until Cx is achieved
10
The specification 13
11
Program vs Specification
Correctness is only in respect to a specification a program without a specification is correct Testing can not ignore the specification Testing can not ignore the program 14
12
Boundary Testing A boundary test tries to establish that the boundary is in the correct spot. Thus, test cases are chosen on the boundary and as close as possible on the open side. “2-on, 1-off” means two on the boundary spread far apart and one just off the boundary in between the other two 17
13
Payroll Problem Wages must be greater than zero and less than 100
Hours must be greater than zero and less than 80 Time and a half is paid on hours over 40
14
Boundary Example - 2on/1off
V I II
15
Triangle Domain
16
Boundaries in the triangle program
Assume max length is 10 What would be 2-on, 1-off for the boundary between isosceles and not-a-triangle?
17
Exam on Tuesday, Oct 8th 1 cribsheet allowed
Both sides, 8.5 by 11, handwritten C++ and SE
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.