Thursday, May 27, 2010
Checklist for testing Reports
Wednesday, May 5, 2010
Statement, Branch/Decision and Path Coverage testing technique with example
How to calculate Statement, Branch/Decision and Path Coverage
Statement Coverage:
In this the test case is executed in such a way that every statement of the code is
executed at least once.
Branch/Decision Coverage:
Test coverage criteria requires enough test cases such that each condition in a decision
takes on all possible outcomes at least once, and each point of entry to a program or
subroutine is invoked at least once. That is, every branch (decision) taken each way,
true and false. It helps in validating all the branches in the code making sure that no
branch leads to abnormal behavior of the application.
Path Coverage:
In this the test case is executed in such a way that every path is executed at least once.
All possible control paths taken, including all loop paths taken zero, once, and multiple
(ideally, maximum) items in path coverage technique, the test cases are prepared based
on the logical complexity measure of a procedural design. In this type of testing every
statement in the program is guaranteed to be executed at least one time. Flow Graph,
Cyclomatic Complexity and Graph Metrics are used to arrive at basis path
How to calculate Statement Coverage, Branch Coverage and Path Coverage?
Draw the flow in the following way-
· Nodes represent entries, exits, decisions and each statement of code.
· Edges represent non-branching and branching links between nodes.
Example:
Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF
Calculate statement coverage, branch coverage and path coverage.
Solution:
The flow chart is-
Statement Coverage (SC):
To calculate Statement Coverage, find out the shortest number of paths following
which all the nodes will be covered. Here by traversing through path 1A-2C-3D-E-4G-5H all
the nodes are covered. So by traveling through only one path all the nodes 12345 are covered,
so the Statement coverage in this case is 1.
Branch Coverage (BC):
To calculate Branch Coverage, find out the minimum number of paths which will
ensure covering of all the edges. In this case there is no single path which will ensure coverage
of all the edges at one go. By following paths 1A-2C-3D-E-4G-5H, maximum numbers of
edges (A, C, D, E, G and H) are covered but edges B and F are left. To covers these edges we can follow 1A-2B-E-4F. By the combining the above two paths we can ensure of traveling
through all the paths. Hence Branch Coverage is 2. The aim is to cover all possible true/false
decisions.
Path Coverage (PC):
Path Coverage ensures covering of all the paths from start to end.
All possible paths are-
1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F
So path coverage is 4.
Thus for the above example SC=1, BC=2 and PC=4.
Memorize these….
100% LCSAJ coverage will imply 100% Branch/Decision coverage
100% Path coverage will imply 100% Statement coverage
100% Branch/Decision coverage will imply 100% Statement coverage
100% Path coverage will imply 100% Branch/Decision coverage
Branch coverage and Decision coverage are same.
*LCSAJ = Linear Code Sequence and Jump.
Tuesday, May 4, 2010
State Transition Testing Technique with example
How to perform State Transition testing technique with example
State Transition Testing
· Models each state a system can exist in
• Models each state transition
• Defines for each state transition
1. start state
2. input
3. output
4. finish state
The process for state transition testing:
a. draw state transition diagram
b. determine start state, input, output and finish state
c. determine coverage level to be achieved (1-switch/switch coverage for these exercises)
d. draw testing tree
e. define tests
When simple one transition complete at that time, it is called 0-switch coverage. If again perform loop then it is called I-switch coverage.
For example
Electric toothbrush
A two-speed electric toothbrush is operated by pressing its one button. The first press of the
button turns the toothbrush from off to speed one, the second press of the button turns it to
speed two When the button is pressed for a third time the electric toothbrush is turned off.
Decision Table Testing Techinque with example
How to perform Decision Table Testing Technique with example
Conditions | Stub | Entry (rules) | |||||
C1 | True | False | |||||
C2 | True | False | True | False | |||
C3 | True | False | - | True | False | - | |
Actions | A1 | x | x | | x | | |
A2 | x | | | | x | | |
A3 | | x | | x | x | | |
A4 | | | x | | | |
Test Case Generation
· Conditions : Inputs
· Actions: Outputs
· Rules: test cases
Example:
| Stub | Rule1 | Rule2 | Rule3 | Rule4 |
Conditions | Flyer member | Yes | Yes | No | No |
Class | Business | Economic | Business | Economic | |
Actions | Upgrade to first | Yes | No | No | No |
Upgrade to business | - | Yes | - | No |
Testcase1: Frequent flyer member, travelling in Business class
Testcase2: Non-member, travelling in Economy class
Possible Answers:
1. Testcase1 – Don’t offer any upgrade, Testcase2 – Don’t offer any upgrade.
2. Testcase1 – Don’t offer any upgrade, Testcase2 – Offer upgrade to Business class.
3. Testcase1 – Offer upgrade to First, Testcase2 – Don’t offer any upgrade.
4. Testcase1 – Offer upgrade to First, Testcase2 – Offer upgrade to Business class.
Follow below steps to answer:
1. Match with conditions in with available rules as input
2. When all the conditions match at that time, verify respective rule section for the answer.
For example in testcase1, frequent flyer member is available with rule1 and rule2. Now check for the travelling business class, here rule 1 only match with the condition. So Rule1 satisfy both the condition 1 and condition2. So according to rule1 testcase 1 allows offer upgrade to First
In testcase 2, non member is available with rule3 and rule4. Now check for the travelling economy class, here rule 4 only match with the condition. So Rule4 satisfy both the condition 1 and condition2. So according to rule4 testcase 2 allows Don’t offer any upgrade.
So answer is ‘Testcase1 – Offer upgrade to First, Testcase2 – Don’t offer any upgrade.’