Beruflich Dokumente
Kultur Dokumente
Testing principles
Types of testing
The various types of testing which are often used
are listed below:
Static testing
Structural testing
Desk checking
Code
walkthrough
Code
Inspection
Unit/code
Functional
testing
Code
coverage
Statement
Coverage
Path
coverage
Condition
coverage
Function
coverage
Code
complexity
Cyclomatic
complexity
Static testing
Static testing requires only the source code of the product,
not the binaries or executables.
Static testing does not involve executing the programs on
computers but involves select people going through the
code to find out whether
The code works according to the functional requirement
The code has been written in accordance with the design
developed
Earlier in the project life cycle
The code for any functionality has been missed out
The code handles errors properly
Static testing can be done by humans or with the help of
specialized tools.
Code review
Code inspection
Desk checking
Code walkthrough
Formal inspection
Structural testing
Structural testing takes into account the code, code structure, internal
design, and how they are coded.
In structural testing tests are actually run by the computer on the built
product, whereas in static testing the product is tested by humans
using just the source code and not the executables or binaries.
Structural testing can be further classified into
Initially the developer can perform certain obvious tests, knowing the
input variables and the corresponding expected output variables.
This can be a quick test that checks out any obvious mistakes
Statement coverage
Program constructs in most conventional programming languages can be
classified as
Object-oriented languages have all of the above and, in addition, a number of other
constructs and concepts. Statement coverage refers to writing test cases that
execute each of the program statements.
Path coverage
A program can start from the beginning and take any of the paths to
its completion.
Condition coverage
In the path coverage testing though we have covered all the paths
possible, it would not mean that the program is fully covered.
Function coverage
This is a new addition to structural testing to identify how many
program functions are covered by test cases.
The advantages that function coverage provides over the other
types of coverage are as follows:
Cyclomatic complexity
In order to convert a standard flowchart into a flow graph to compute
cyclomatic complexity, the following steps are taken:
Identify the predicates or decision points in the program.
Ensure that the predicates are simple
Combine all sequential statements into a single node
When a set of sequential statements are followed by a simple
predicate, combine all the sequential statements and the predicate
check into one node and have two edges emanating from this one
node. Such nodes with two edges emanating from them are called
predicate nodes.
Make sure that all the edges terminate at some node; add a node to
represent all the sets of sequential statements at the end of the
program
true
If( A or B)
false
True
True
IF ( B)
IF(A)
False
False
Cyclomatic complexity
A hypothetical program with no decision node
# of independent paths = 1
# of nodes, N = 2
# of edges, E = 1
Cyclomatic complexity = E-N+2 = 1
# of predicate nodes, P=0
End
Cyclomatic complexity = P + 1 = 1
Cyclomatic complexity
Converting a conventional flowchart to a flow graph;
Cyclomatic complexity
Adding one decision node
# of independent paths = 2
# of nodes, N=4
# of edges, E=4
Cyclomatic complexity=E-N+2=2
# of predicate nodes, P=1
Cyclomatic complexity = P +1 = 2
End
Cyclomatic complexity
Complexity
What it means
1 - 10
10-20
20-40
>40
Cyclomatic complexity
Cyclomatic complexity = number of predicate nodes + 1
Cyclomatic complexity = E N + 2
Where, E is the number of edges and N is the number of nodes
Description
Priorit
y
Test
conditions
Test case
IDs
Phase of
testing
BR-01
Lock_001
Unit,
Component
BR-02
Lock_002
Unit,
Component
BR_03
Lock_003
Lock_004
Component
BR-04
No other object
can be used to lock
Lock_005
Lock_006
Lock_007
Integration
BR-05
No other object
can be used to
unlock
Lock_008
Lock_009
Integration
Req.ID
Priority
Test
cases
Total
test
cases
Test
cases
passed
Test
cases
failed
% pass
No. of
defects
BR-01
Lock-01
100
BR-02
Lock_02 1
100
BR-03
Lock_03,
04
50
BR-04
Lock_05,
06,07
67
BR-05
Lock_08,
09,10
100
BR-06
Lock_11
100
BR-07
Lock_12
100
BR-08
Total
12
10
83
12
Input 1
Input 2
Current
state
Unlocked
Expected
output
locked
BR-01
Key 123
BR-01
Key 123
Turn
clockwise
Turn
clockwise
Locked
No
change
No
Change
Unlock
BR-02
Key 123
Turn
anticlockwise
Unlocked
BR-02
Key 123
Turn
anticlockwise
Locked
BR-04
Hairpin
Turn
clockwise
Locked
No
change
Negative testing
Negative testing is done to show that the product does not fail
when an unexpected input is given
The purpose of negative testing is to try and break the system.
Negative testing covers scenarios for which the product is not
designed and coded
A negative test would be a product not delivering an error
when it should or delivering an error when it should not.
In positive testing if all documented requirements are covered,
then coverage can be considered to be 100 percent.
In contrast, there is no end to negative testing, and 100 percent
coverage in negative testing is impractical.
Negative testing requires a high degree of creativity among the
testers to cover as many unknowns as possible to avoid
failure at customer site.
Input 1
Input 2
Current
state
Expected
output
Lock
Lock
Unlock
Unlock
Thin piece
of wire
Unlock
unlock
Hit with a
stone
Lock
Lock
Turn
anticlockwise