Software Testing Structural testing 1
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;
Control Flow Graph TTYP1 – what are the paths through this code?
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
Domains in testing 12
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
TTYP 2 What is a set test cases for the “path” subdomains for the triangle code?
Typical Structural Coverage C0 – every statement C1 – every branch
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
The specification 13
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
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
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
Boundary Example - 2on/1off V I II
Triangle Domain
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?
Exam on Tuesday, Oct 8th 1 cribsheet allowed Both sides, 8.5 by 11, handwritten C++ and SE