Software Testing Software Testing
CISC 323
Winter 2006
- Prof. Lamb
- Prof. Kelly
malamb@cs.queensu.ca kelly-d@rmc.ca
Software Testing Software Testing CISC 323 Winter 2006 Prof. Lamb - - PowerPoint PPT Presentation
Software Testing Software Testing CISC 323 Winter 2006 Prof. Lamb Prof. Kelly malamb@cs.queensu.ca kelly-d@rmc.ca Included in Courseware Reference material for the lectures 19 pages from Software Testing, A Craftsmans
Winter 2006
malamb@cs.queensu.ca kelly-d@rmc.ca
2
3
Illustration of difficulties: next slides
4
5
6
7
– To provide reasoned ways of generating test cases – To produce test cases systematically
– To help in reproducibility of the tests – To address the”when are we done?” problem
found
– To allow better planning – To allow the use of different techniques to address different issues – To provide data for debugging
8
9
– Based on the finding that errors seem to cluster at boundaries
– software failures are rarely the result of the simultaneous
– Holding the values of all but one input variable at their nominal values and letting that one variable assume its extreme values
maximum
10
11
their ranges
12
– {month, day}
tested by this technique
13
14
15
16
require exactly the same behavior from each value in the class
fails for each of the values in that class
equivalence classes of invalid inputs
17
run
testing
18
– age, breed, colour, M/F, neutered
– age, colour, M/F, neutered
– Mammal: species, age, restricted, endangered, origin – Other: Phylum, Class, Order, Family, Genus, Species, restricted, endangered, origin
19
– Classification:
– Age:
– Breed
– Colour
tiger, …
– M/F – Neutered – Y/N – Exotic – Mammal, other – Mammal Species
lemur, wolf, raccoon, harbour seal, …
– Restricted – Y/N – Endangered – Y/N – Origin
Australia, Brazil, …
– Phylum – alpha (0-40) – Class – alpha (0-40) – Order – alpha (0-40) – Family – alpha (0-40) – Genus – alpha (0-40) – Species other – alpha (0-40)
20
requirement/design as specified (which it will not if a defect exists), then some values in the equivalence class will produce a different actual behavior than expected
– Those values may not be chosen during equivalence class testing
21
22
– Touch each statement once
– Execute each branch after a condition statement
– Execute all paths through the code
– A compromise
23
void tst(int x) { if (x>0)
pos = pos+1;
if (x%2==0)
even = even+1;
return; }
– Statement Coverage: tst(2) – Branch Coverage: tst(-1),tst(2) – Path Coverage: tst(-2),tst(-1),tst(1),tst(2)
24
– Many tools available to track statement coverage
have been executed
– Could slow your code down unacceptably
– Often used to decide adequate testing
– May have special conditions, dead code, error routines
– It may be more cost effective to inspect uncovered parts than it is to cover them by testing
25
26
#include <stdio.h> #include <stdlib.h> #include <math.h> main(argc, argv) int argc; char* argv[]; { int sideA; int sideB; int sideC; double s; double Area; sideA = atoi(argv[1]); sideB = atoi(argv[2]); sideC = atoi(argv[2]); if ( (sideA == sideB) && (sideA == sideC ) ) { s = 0.5 * (sideA + sideB + sideC); Area = sqrt (s / (s - sideA) * (s - sideB) * (s - sideC) ); printf ( "area = %g\n", Area) ; } Else { puts ("not an equilateral triangle") ; return 0; }
27
– use inputs
– output
– use inputs
– output
triangle
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
– Use engineering judgment to devise special value testing
– Find standard algorithms in textbooks – Use well-established math libraries