Sunday, September 25, 2011


White Box Testing: 

White box testing is a method of software testing, in which we test the internal work flow, structures and logic of the application.  A QA should have the good programming skill for doing this and design test cases as well.

A failure of a white box test may result in a change that requires all black box testing to be repeated and white box testing paths to be reviewed and possibly changed.

It is usually done at the unit level. It can test paths within a unit, paths between units during integration, and between subsystems during a system level test. Though this method of test design can uncover many errors or problems, it might not detect unimplemented parts of the specification or missing requirements.

The tester chooses inputs to exercise paths through the code and determine the appropriate outputs. This is analogous to testing nodes in a circuit.

White-box test design techniques include:

§                     Control flow testing
§                     Data flow testing
§                     Branch testing
§                     Path testing

Techniques used are:

Basis Path Testing
Flow Graph Notation
Control Structure Testing
1.      Condition Testing
2.      Data Flow testing
Loop Testing
1.      Simple Loops
2.      Nested Loops
3.      Concatenated Loops
4.      Unstructured Loops

Why we do White Box Testing?

To ensure:
  1. ·                     That all independent paths within a module have been exercised at least once.
  2. ·                    All logical decisions verified on their true and false values.
  3. ·                     All loops executed at their boundaries and within their operational bounds internal data structures validity.


·                      
Need of White Box Testing?

To discover the following types of bugs:

·                     Logical error tend to creep into our work when we design and implement functions, conditions or controls that are out of the program
·                     The design errors due to difference between logical flow of the program and the actual implementation
·                     Typographical errors and syntax checking.


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?

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 3 www.ajoysinigha.info 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.

No comments:

Post a Comment