White Box Testing Techniques
Hi All,
I faced lots of difficulties while gathering all informations about an IMPORTANT topic :- White Box Testing Technique. I don't want that others to come under same circumstances. So i am trying to resolve a bit of your problem with my point of view and through this post. I hope you all will like my post as informative and interesting.
White Box Testing
- White-box testing deals with specification and design as well as the underlying code of the software.
- Programming language dependent
White Box Testing Techniques
- Statement Coverage
- Decision Coverage
- Condition Coverage
- Decision/Condition Coverage
- Multiple Condition Coverage
The explaination of the techniques is as follows:-
Statement Coverage
- Guarantee that all independent paths within a module have been exercised at least once.
- This method enables the designer to derive a logical complexity measure of a procedural design and use it as a guide for defining a basis set of execution paths.
- For every statement in the code, there is at least one test case which causes the program to execute that statement
Examples of Statement Coverage
Parish DDL file:-It look like this
Begin
{IF DB_ID (N'parish') IS NOT NULL
DROP DATABASE parish;
}
end;
CREATE DATABASE parish;
USE parish
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[R_Death_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Death]'))
ALTER TABLE [dbo].[Death] DROP CONSTRAINT [R_Death_1]….
If Parish database is already present then will be dropped and then a new Parish database will be created.
If we take a look then we can find that its all about "Droping old database and Creating a new database". But for the first time the dropping table command will not get executed because we do not have Parish database. So for the second time the whole code will be executed rather i should say all the statements will be executed.
Decision Coverage
- Execute each decision direction at least once.
- Exercise all logical decisions on their true and false sides
For e.g., in a If-else condition (if b=1 then a+b else a-b). In this if the condition is always true all the statements are executed, but branch coverage is not achieved. - For every decision in the code, there is at least one test case that evaluates the decision to false
- For every decision in the code, there is at least one test case that evaluates the decision to true
Condition Coverage
- Design test cases such that each possible outcome of each condition in a decision (composite condition) occurs at least once
- Condition testing is a test case design method that exercises the logical conditions contained in a program module.
- Test cases should be designed such that each gets value true and false at least once
Take an example of calculating Premium for an employee as follows:-
premium = 500;
lif ((age<25) sex="=" sex="=">45) && (age<65))>
This example consists of two conditions as follows:-
- Logical operator: &&, , !, etc.
- Every decision contains one or more conditions e.g. ((age<25) sex="=">
Decision/Condition Coverage
In this type of coverage both decision as well as condition coverage must be satisfied.
For e.g.,
One with ((age<25) sex="=" sex="=">45) && (age<65)) sex="=">45) && (age<65))>
Multiple Condition Coverage
- Design test cases for each combination of conditions
- Implies decision-, condition-, decision and condition, modified branch/condition coverage
Now let us sum up all the knowledge with an easy example of finding greater number out of two numbers. this may help a tester to write test cases according to the techniques:-
Begin ----------------> Technique 1
{ int A , B; ----------------> Technique 1
If (A>B) ----------------> Technique 1, 2, 3, 4
then A is greater;
Else ----------------> Technique 1
If (B > A) ----------------> Technique 1, 2, 3, 4
then B is greater;
Else Both are equal;
}
}
Comments