Documente Academic
Documente Profesional
Documente Cultură
Slide 1
Lesson Objectives
Understand a range of different software testing techniques and strategies Be able to apply a specific (automated) unit testing method to your group project
Slide 2
Requires test data (inputs) and knowledge of the expected output. A test case is the tuple (i, o),where i is the test data and o=S(i) for S the software under test.
Slide 3
Slide 4
Slide 5
Slide 6
Slide 7
Testing in development
Component testing
Unit or module testing Integration testing
Slide 8
Slide 9
Testing Strategies
Bottom-up
Test Driver needed
Top-down
Test stub needed
Slide 10
Testing Methods
Dynamic testing vs Static testing (static analysis) Black Box Testing vs White Box Testing Statistical Testing
Slide 11
Regression testing
Retesting to ensure previously working code does not fail as a result of changes Should be applied irrespective of testing strategy or method
Slide 12
White-box testing
Determining test cases from a knowledge of the internal logic of the software
Slide 13
Read(ScoreFile, Score); 6 } /* Compute the mean and print the result */ 7 if (NumberOfScores > 0) { Mean = SumOfScores / NumberOfScores; printf( The mean score is %f\n, Mean); } else printf (No scores found in file\n); 9 }
Slide 15
Slide 16
one value)
Slide 17
Test Cases
Test case 1 : ? (To execute loop exactly once) Test case 2 : ? (To skip loop body) Test case 3: ?,? (to execute loop more than once)
Slide 18
Slide 19
Visit-each-loop (7) <2 11>, <2 10 12 14>, <2 10 12 13 12 14>, <1 3 5 6 9>, <1 3 5 6 7 8 9>, <1 4 6 9>, <1 4 6 7 8 9> Simple paths (6) <2 11>, <2 10 12 14>, <1 3 5 6 9>, <1 3 5 6 7 8 9>, <1 4 6 9>, <1 4 6 7 8 9> Basis paths (6) <2 11>, <2 10 12 14>, <2 10 12 13 12 14>, <1 3 5 6 9>, <1 3 5 6 7 8 9>, <1 4 6 9>, <1 4 6 7 8 9> Branch (4) <2 11>, <2 10 12 13 12 14>, <1 3 5 6 9>, <1 4 6 7 8 9> Statement (2) <2 10 12 14>, <1 3 5 6 7 8 9>
Slide 20
Infeasible paths
A C F t t B f
A B C D E F G
Input(score); If score < 45 then print (fail) else print (`pass); If score > 80 then print (with distinction); End
E f G
Slide 21
Condition testing can be done with 2 test cases (A=2, B=0, X=4), (A=1, B=1, X=1)
true e X=X+1
Multiple condition testing can be done with 4 test cases (A=2, B=0, X=4), (A=2, B=1, X=1), (A=1, B=0, X=2), (A=1, B=1, X=1)
Slide 22
Black-box testing
Equivalence partitioning Boundary value analysis Cause-effect graphing Error guessing Random testing Statistical testing Syntax directed testing State transition testing
Slide 23
Equivalence partitioning
0 < x < 1000 x<1 x>999
y=0
Input space
0< y < 6
y>5
Slide 24
eA
eA
eA
eA
eA eA
e first in A
e last in A
Slide 25
Slide 26
Test number 1 2 3 4
Random Numbers 29 11 47 52 26 94 62 98 39 78 82 65 83 32 58 41 36 17 36 49 96 82 20 77
Slide 27
Program ECHO Input ch If time = 23:59:59 and date = 31.12.2005 then destroy all files else output ch
input ch time=23:59:59 and date =31.12.2005? f output ch
Extensive black box testing would not find the obvious fault here
Slide 28
JUnit
Fantastic automated tool support for unit testing in Java For each method you write you build the test case at the same time Fully integrated into Java IDEs Core part of Extreme Programming
Slide 29
Assert.assertTrue(expected.equals(result)); } }
Slide 30
Slide 31
Lesson Summary
Testing aims to find faults Testing must be properly planned Effective testing necessarily involves a range of methods Testing is still a black art, but many rules and heuristics are available Unit testing is known to be one of the most cost-effective QA procedures. You can do unit testing with full automated support using JUnit.
Slide 32