code testing
DESCRIPTION
CODE TESTING. Principles and Alternatives. Testing - Basics. goal - find errors focus is the source code (executable system) test team wants to achieve an appropriate level of confidence in the product style - run test-cases input: specification and source code - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/1.jpg)
1
CODE TESTING
Principles and Alternatives
![Page 2: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/2.jpg)
2
Testing - Basics• goal - find errors
– focus is the source code (executable system)– test team wants to achieve an appropriate level
of confidence in the product• style - run test-cases
– input: specification and source code– action: derive test-cases & evaluate results– have enough test-cases been executed?
![Page 3: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/3.jpg)
3
How “complete” is Testing?
• If testing includes all possible input combinations, it is equivalent to a proof.
• In all other cases, testing establishes only a measure of confidence, a belief, that the systems works according to specification and within quality parameters.
![Page 4: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/4.jpg)
4
The Art of Testing
• Find a good set of test-cases– cover all aspects of the system– derive test-cases in a structured way
• Know when to stop testing– trade-off between completeness & cost– “measure” relative completeness
![Page 5: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/5.jpg)
5
When to Stop
• “completeness”:– You have established test-cases which
cover all aspects in sufficient quantity– You have executed all test-cases and
achieved valid results• “test the test”
– e.g. Monte Carlo method
![Page 6: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/6.jpg)
6
Test-Cases - Basics
• test-cases are derived during all phases of the development cycle
• determine expected results before running a test-case
• never throw away test-cases & results• look for errors where you found errors
before• allocate time and money
![Page 7: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/7.jpg)
7
Types of Test-Cases
• derive test-cases for– valid, expected inputs– invalid unexpected inputs (garbage)– test, if the system does less than
specified– test, if the system does more than
specified
![Page 8: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/8.jpg)
8
Two Major Stages of Testing
• module (unit) testing
• system & integration testing
![Page 9: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/9.jpg)
9
Module Testing
• part of the implementation phase• establish confidence (correctness) in single,
isolated module• test module’s functionality• test module’s interface from the perspective of
the module (from the internal perspective)• Two major forms:
– black box & white box testing
![Page 10: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/10.jpg)
10
Integration Testing
• major task of the testing phase• establish confidence (correctness) in the
complete, assembled system• test the system structure (design)• focus on control, communication, interfaces,
performance (other system qualities)• use of stubs, test-beds, data generators
![Page 11: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/11.jpg)
11
0
1 2 3
1.1 1.2 1.3 2.1 2.2 3.1 3.2
crt db prt crt
IntegrationTesting
![Page 12: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/12.jpg)
12
Black Box Testing - The Concept
• module level• no knowledge of actual implementation
– “black box”• driven by the module’s external
“appearance”– based on specification & interface
![Page 13: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/13.jpg)
13
Black Box Testing - Discussion
• advantages:– finds missing functionality– independent from code-size and
complexity (?)– finds some coding errors (by chance)
• constraints:– no systematic search for low level errors– specification errors not found
![Page 14: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/14.jpg)
14
Black Box Testing - Handling
• partition test-cases into functional groups• follow the suggestions for “types of test-cases”• examine unusual cases
– boundary values– null values– extremes
• generate additional random test-cases
![Page 15: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/15.jpg)
15
White Box Testing - The Concept
• module level• focus on structure of the actual
implementation (source code)– “white box”
• does not take into account the specification of the module’s external behaviour
![Page 16: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/16.jpg)
16
White Box Testing - Discussion• advantages:
– finds errors on the code level– typically based on a very systematic
approach, covering the complete internal module structure
• constraints:– does not find missing / additional functionality– does not really check the interface– difficult for large and complex modules
![Page 17: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/17.jpg)
17
White box and black box testing complement each other.
Always use both forms of module testing for a complete test.
![Page 18: CODE TESTING](https://reader035.vdocuments.site/reader035/viewer/2022072014/56812d40550346895d9244ea/html5/thumbnails/18.jpg)
18
End of Section 4e