Ch6 (B) - Software Testing and Debugging
Ch6 (B) - Software Testing and Debugging
Software Testing
■ Software Testing is a critical element of software quality
& Debugging assurance and represents the ultimate review of
specification, design and coding.
■ It is concerned with the actively identifying errors in
software.
Lecture 6(b) ■ Testing is dynamic assessment of the software
BSIT 6th ◆ Sample input
1 2
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
■ Software Testing is the process of exercising a program with ■ Testing is different from debugging
the specific intent of finding errors prior to delivery to the ■ Debugging is removal of defects in the software, a
end user. correction process
■ It is the process of checking to see if software matches its
■ Testing is an assessment process
specification for specific cases called Test Case.
■ Testing consumes 40-50% of the development effort
■ A Good Test Case is one that has a high probability of finding
undiscovered error.
3 4
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
What can Testing Show? Who Tests the Software?
Errors
Requirements Consistency
Performance
5 6
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
Testing Paradox
■ A controlled/observed environment, because tests must be ■ A good test has a high probability of finding an error.
exactly reproducible ◆ The tester must understand the software and attempt to develop
9 10
Thanks to M8034 @ Peter Lo 2006
Thanks to M8034 @ Peter Lo 2006
11 12
Strategies
Thanks to M8034 @ Peter Lo 2006
White Box Testing Technique (till slide 23) White Box Testing Technique
■ White box testing is a test case design method that ■ White Box Testing of software is predicated on close
uses the control structure of the procedural design examination of procedural detail.
to derive test cases. ■ Logical paths through the software are tested by
... our goal is to providing test cases that exercise specific sets of
ensure that all conditions and / or loops.
statements and ■ The status of the program may be examined at various
conditions have
been executed
points to determine if the expected or asserted status
at least once ... corresponds to the actual status.
13 14
Thanks to M8034 @ Peter Lo 2006
■ Tests are derived from an examination of the source code for the ■ Using white box testing methods, the software engineer
modules of the program. can derive test cases that:
■ These are fed as input to the implementation, and the execution ◆ Guarantee that all independent paths within a module
traces are used to determine if there is sufficient coverage of the have been exercised at least once;
program source code
◆ Exercise all logical decisions on their true or false
sides;
◆ Execute all loops at their boundaries and within their
operational bounds ; and
◆ Exercise internal data structures to ensure their validity.
15 16
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
Exhaustive Testing
loop < 20 X
17
Selective Testing
Selected path
loop < 20 X
18
Thanks to M8034 @ Peter Lo 2006
Condition Testing
19
Thanks to M8034 @ Peter Lo 2006
■ The Data flow testing method selects test paths of a ■ Loop testing is a white-box testing technique that focuses
program according to the locations of definitions and exclusively on the validity of loop constructs
uses of variables in the program ■ Four classes of loops:
1. Simple loops
2. Concatenated loops
3. Nested loops
4. Unstructured loops
■ Where n is the maximum number of allowable ■ Start at the innermost loops. Set all other loops to
passes through the loop: minimum values
■ Conduct simple loop tests for the innermost loop while
◆ Skip the loop entirely
holding the outer loops at their minimum iteration
◆ Only one pass through the loop parameter values. Add other tests for out-of -range or
◆ Two passes through the loop excluded values
■ Work outward, conducting tests for the next loop
◆ m passes through the loop where m<n
Simple but keeping all other outer loops at minimum values
◆ n-1, n, n+1 passes through the loop loop and other nested loops to "typical" values Nested
■ Continue until all loops have been tested Loops
22 23
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
■ Black Box Testing focus on the functional requirements of the ■ Black box testing attempts to find errors in the
software, i.e. derives sets of input conditions that will fully exercise following categories:
all functional requirements for a program.
◆ Incorrect or missing functions
◆ Interface errors
◆ Performance errors
Input Events 24 25
Thanks to M8034 @ Peter Lo 2006
■ All the versions are executed in parallel with a real- ■ Code Auditors
time comparison of results to ensure consistency. ■ Assertion Processors
◆ If the output from each version is the same, then it is
■ Test File Generators
assumed that all implementations are correct.
■ Test Data Generators
◆ If the output is different, each of the applications is
investigated to determine if a defect in one or more ■ Test Verifiers
versions is responsible for the difference. ■ Output Comparators
30 31
Thanks to M8034 @ Peter Lo 2006
35
M8034 @ Peter Lo 2006 65 Thanks to M8034 @ Peter Lo 2006
testing
■ Integration Tests
◆ Focuses on the design and construction of software
architecture; black box testing is most prevalent with
limited white box testing.
■ High-order Tests
◆ Conduct validation and system tests. Makes use of black box
testing exclusively (such as Validation Test, System Test,
Alpha and Beta Test, and other Specialized Testing).
37
M8034 @ Peter Lo 2006 67 Thanks to M8034 @ Peter Lo 2006
Unit Testing Unit Testing
■ Unit testing focuses on the Module
to be
results from coding. Tested
Module ■ Each module is tested in turn Interface
to be and in isolation from the Local Data Structures
Tested others. Boundary Conditions
■ Uses white-box techniques. Independent Paths
Results
Error Handling Paths
Software
Engineer Test Cases
Test Cases
38 39
Thanks to M8034 @ Peter Lo 2006
41
◆ Stress
◆ Performance
■ A system test that forces software to fail in a ■ Security testing attempts to verify that protection
variety of ways and verifies that recovery is mechanisms built into a system will in fact protect it
properly performed. from improper penetration.
■ If recovery is automatic, re-initialization, check- ■ Particularly important to a computer-based system that
pointing mechanisms, data recovery, and restart are manages sensitive information or is capable of causing
each evaluated for correctness. actions that can improperly harm individuals when
■ If recovery is manual, the mean time to repair is targeted.
evaluated to determine whether it is within acceptable
limits.
85 86
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
■ Stress Testing is designed to confront programs with ■ Test the run-time performance of software within the
abnormal situations where unusual quantity frequency, context of an integrated system.
or volume of resources are demanded ■ Extra instrumentation can monitor execution
■ A variation is called sensitivity testing; intervals, log events as they occur, and sample
◆ Attempts to uncover data combinations within valid machine states on a regular basis
input classes that may cause instability or improper ■ Use of instrumentation can uncover situations that lead
processing to degradation and possible system failure
89 90
Thanks to M8034 @ Peter Lo 2006
■ A bug is a part of a program that, if executed in the ■ The symptom and the cause may be geographically remote
right state, will cause the system to deviate from its ■ The symptom may disappear when another error is
corrected
specification (or cause the system to deviate from
■ The symptom may actually be caused by non-errors
the behavior desired by the user).
■ The symptom may be caused by a human error that is not
easily traced
■ It may be difficult to accurately reproduce input conditions
■ The symptom may be intermittent. This is particularly
common in embedded systems that couple hardware and
software inextricably
■ The symptom may be due to causes that are distributed
across a number of tasks running on different processors
91 92
95 96
Thanks to M8034 @ Peter Lo 2006 Thanks to M8034 @ Peter Lo 2006
Debugging Effort Consequences of Bugs
infectious
Time required
to diagnose the damage
annoying
mild
Bug Type
Bug Categories: function-related bugs,
system-related bugs, data bugs, coding bugs,
design bugs, documentation bugs, standards
violations, etc.
101 102
Thanks to M8034 @ Peter Lo 2006
Thanks to M8034 @ Peter Lo 2006