Unit-2: Types of Testing Black Box Testing: What Is & When?
Unit-2: Types of Testing Black Box Testing: What Is & When?
In this method, the tester selects a function and gives input value to examine its
functionality, and checks whether the function is giving expected output or not. If
the function produces correct output, then it is passed in testing, otherwise failed.
The test team reports the result to the development team and then tests the next
function. After completing testing of all functions if there are severe problems,
then it is given back to the development team for correction.
Test procedure :
The test procedure of black box testing is a kind of process in which the tester has
specific knowledge about the software's work, and it develops test cases to check
the accuracy of the software's functionality.
It does not require programming knowledge of the software. All test cases are
designed by considering the input and output of a particular function.A tester
knows about the definite output of a particular input, but not about how the result is
arising.
Test cases :
Test cases are created considering the specification of the requirements. These test
cases are generally created from working descriptions of the software including
requirements, design parameters, and other specifications. For the testing, the test
designer selects both positive test scenario by taking valid input values and adverse
test scenario by taking invalid input values to determine the correct output. Test
cases are mainly designed for functional testing but can also be used for
non-functional testing. Test cases are designed by the testing team, there is not any
involvement of the development team of software.
Whenever we do the testing by boundary value analysis, the tester focuses on,
while entering boundary value, whether the software is producing correct output or
not.
Boundary values are those that contain the upper and lower limit of a variable.
Assume that, age is a variable of any function, and its minimum value is 18 and the
maximum value is 30, both 18 and 30 will be considered as boundary values.
The basic assumption of boundary value analysis is, the test cases that are created
using boundary values are most likely to cause an error.
There is 18 and 30 are the boundary values that's why tester pays more attention to
these values, but this doesn't mean that the middle values like 19, 20, 21, 27, 29 are
ignored. Test cases are developed for each and every value of the range.
Testing of boundary values is done by making valid and invalid partitions. Invalid
partitions are tested because testing of output in adverse condition is also essential.
The software system will be passed in the test if it accepts a valid number and
gives the desired output, if it is not, then it is unsuccessful. In another scenario, the
software system should not accept invalid numbers, and if the entered number is
invalid, then it should display error massage.
If the software which is under test, follows all the testing guidelines and
specifications then it is sent to the releasing team otherwise to the development
team to fix the defects.
The equivalence partitions are derived from requirements and specifications of the
software. The advantage of this approach is, it helps to reduce the time of testing
due to a smaller number of test cases from infinite to finite. It is applicable at all
levels of the testing process.
3. Decision Table :
Decision Table Technique is a systematic approach where various input
combinations and their respective system behavior are captured in a tabular form.
It is appropriate for the functions that have a logical relationship between two and
more than two inputs.
Decision table technique is one of the widely used case design techniques for black
box testing. This is a systematic approach where various input combinations and
their respective system behavior are captured in a tabular form.
That's why it is also known as a cause-effect table. This technique is used to pick
the test cases in a systematic manner; it saves the testing time and gives good
coverage to the testing area of the software application.
Decision table technique is appropriate for the functions that have a logical
relationship between two and more than two inputs.
This technique is related to the correct combination of inputs and determines the
result of various combinations of input. To design the test cases by decision table
technique, we need to consider conditions as input and actions as output.
Most of us use an email account, and when you want to use an email account, for
this you need to enter the email and its associated password.
If both email and password are correctly matched, the user will be directed to the
email account's homepage; otherwise, it will come back to the login page with an
error message specified with "Incorrect Email" or "Incorrect Password."
Now, let's see how a decision table is created for the login function in which we
can log in by using email and password. Both the email and the password are the
conditions, and the expected result is action.
In the table, there are four conditions or test cases to test the login function. In the
first condition if both email and password are correct, then the user should be
directed to account's Homepage.
In the second condition if the email is correct, but the password is incorrect then
the function should display Incorrect Password. In the third condition if the email
is incorrect, but the password is correct, then it should display Incorrect Email.
Now, in fourth and last condition both email and password are incorrect then the
function should display Incorrect Email.
In this example, all possible conditions or test cases have been included, and in the
same way, the testing team also includes all possible test cases so that upcoming
bugs can be cured at testing level.
In order to find the number of all possible conditions, tester uses 2n formula where
n denotes the number of inputs; in the example there is the number of inputs is 2
(one is true and second is false).
While using the decision table technique, a tester determines the expected output, if
the function produces expected output, then it is passed in testing, and if not then it
is failed. Failed software is sent back to the development team to fix the defect.
The term 'white box' is used because of the internal perspective of the system. The
clear box or white box or transparent box name denote the ability to see through
the software's outer shell into its inner workings.
Developers do white box testing. In this, the developer will test every line of the
code of the program. The developers perform the White-box testing and then send
the application or the software to the testing team, where they will perform the
black box testing and verify the application along with the requirements and
identify the bugs and send it to the developer.
The developer fixes the bugs and does one round of white box testing and sends it
to the testing team. Here, fixing the bugs implies that the bug is deleted, and the
particular feature is working fine on the application.
Here, the test engineers will not include in fixing the defects for the following
reasons:
○ Fixing the bug might interrupt the other features. Therefore, the test engineer
should always find the bugs, and developers should still be doing the bug
fixes.
○ If the test engineers spend most of the time fixing the defects, then they may
be unable to find the other bugs in the application.
Test cases for white box testing are derived from the design phase of the software
development lifecycle. Data flow testing, control flow testing, path testing, branch
testing, statement and decision coverage all these techniques used by white box
testing as a guideline to create an error-free software.
White box testing follows some working steps to make testing manageable and
easy to understand what the next task to do. There are some basic steps to perform
white box testing.
Types :
The white box testing contains various tests, which are as follows:
○ Path testing
○ Loop testing
○ Condition testing
○ Testing based on the memory perspective
○ Test performance of the program
1. Path testing :
In the path testing, we will write the flow graphs and test all independent paths.
Here writing the flow graph implies that flow graphs are representing the flow of
the program and also show how every program is added with one another as we
can see in the below image:
And test all the independent paths implies that suppose a path from main() to
function G, first set the parameters and test if the program is correct in that
particular path, and in the same way test all other paths and fix the bugs.
Example :
2. Loop testing
In the loop testing, we will test the loops such as while, for, and do-while, etc. and
also check for ending conditions if working correctly and if the size of the
conditions is enough.
For example: we have one program where the developers have given about 50,000
loops.
{
while(50,000)
……
……
}
We cannot test this program manually for all the 50,000 loops cycle. So we write a
small program that helps for all 50,000 cycles, as we can see in the below program,
that - Test P is written in the similar language as the source code program, and this
is known as a Unit test. And it is written by the developers only.
Test P
{
……
…… }
As we can see in the below image that, we have various requirements such as 1, 2,
3, 4. And then, the developer writes the programs such as program 1,2,3,4 for the
parallel conditions. Here the application contains the 100s line of codes.
The developer will do the white box testing, and they will test all the five programs
line by line of code to find the bug. If they found any bug in any of the programs,
they will correct it. And they again have to test the system then this process
contains lots of time and effort and slows down the product release time.
Now, suppose we have another case, where the clients want to modify the
requirements, then the developer will do the required changes and test all four
program again, which take lots of time and efforts.
In this, we will write test for a similar program where the developer writes these
test code in the related language as the source code. Then they execute these test
code, which is also known as unit test programs. These test programs linked to the
main program and implemented as programs.
Therefore, if there is any requirement of modification or bug in the code, then the
developer makes the adjustment both in the main program and the test program and
then executes the test program.
3. Condition testing :
In this, we will test all logical conditions for both true and false values; that is, we
will verify for both if and else conditions.
For example:
if(condition) - true
{
…..
……
……
}
else - false
{
…..
……
……
}
The above program will work fine for both the conditions, which means that if the
condition is accurate, and then else should be false and conversely.
For example,
Int a=15;
Int b=20;
String S= "Welcome";
….
…..
…..
….
…..
Int p=b;
Create user()
{
……
……
….. 200's line of code
}
In the above code, we can see that the integer a has never been called anywhere in
the program, and also the function Create user has never been called anywhere in
the code. Therefore, it leads us to memory consumption.
We cannot remember this type of mistake manually by verifying the code because
of the large code. So, we have a built-in tool, which helps us to test the needless
variables and functions. And, here we have the tool called Rational purify.
Suppose we have three programs such as Program P, Q, and R, which provides the
input to S. And S goes into the programs and verifies the unused variables and then
gives the outcome. After that, the developers will click on several results and call
or remove the unnecessary function and the variables.
This tool is only used for the C programming language and C++ programming
language; for another language, we have other related tools available in the market.
○ The developer does not use the available in-built functions; instead they
write the full features using their logic. Therefore, it leads us to waste of
time and also postpone the product releases.
5. Test the performance (Speed, response time) of the program :
The application could be slow for the following reasons:
○ When logic is used.
○ For the conditional cases, we will use or & and adequately.
○ Switch case, which means we cannot use nested if, instead of using a switch
case.
As we know that the developer is performing white box testing, they understand
that the code is running slow, or the performance of the program is also getting
deliberate. And the developer cannot go manually over the program and verify
which line of the code is slowing the program.
To recover with this condition, we have a tool called Rational Quantify, which
resolves these kinds of issues automatically. Once the entire code is ready, the
Rational Quantify tool will go through the code and execute it. And we can see the
outcome in the result sheet in the form of thick and thin lines.
Here, the thick line specifies which section of code is time-consuming. When we
double-click on the thick line, the tool will take us to that line or piece of code
automatically, which is also displayed in a different color. We can change that code
and again and use this tool. When the order of lines is all thin, we know that the
presentation of the program has been enhanced. And the developers will perform
the white box testing automatically because it saves time rather than performing
manually.
1. Statement Coverage :
In this technique, the aim is to traverse all statements at least once. Hence, each
line of code is tested. In the case of a flowchart, every node must be traversed at
least once. Since all lines of code are covered, it helps in pointing out faulty code.
Statement Coverage Example
2. Branch Coverage :
In this technique, test cases are designed so that each branch from all decision
points is traversed at least once. In a flowchart, all edges must be traversed at least
once.
4 test cases are required such that all branches of all decisions are covered, i.e, all
6. Loop Testing :
Loops are widely used and these are fundamental to many algorithms hence, their
testing is very important. Errors often occur at the beginnings and ends of loops.
● Simple loops: For simple loops of size n, test cases are designed that:
1. Skip the loop entirely
2. Only one pass through the loop
3. 2 passes
4. m passes, where m < n
5. n-1 ans n+1 passes
● Nested loops: For nested loops, all the loops are set to their minimum
count, and we start from the innermost loop. Simple loop tests are
conducted for the innermost loop and this is worked outwards till all the
loops have been tested.
● Concatenated loops: Independent loops, one after another. Simple loop
tests are applied for each. If they’re not independent, treat them like
nesting.
❖ Static Testing :
Introduction to Static Testing :
Static testing is a verification process used to test the application without
implementing the code of the application. And it is a cost-effective process.
To avoid the errors, we will execute Static testing in the initial stage of
development because it is easier to identify the sources of errors, and it can fix
easily.
In other words, we can say that Static testing can be done manually or with the
help of tools to improve the quality of the application by finding the error at the
early stage of development; that is also called the verification process.
Static testing also helps us to identify those errors which may not be found by
Dynamic Testing.
Step1: To review the design of the application entirely, we will perform the
inspection process.
Step2: After that, we will use a checklist for each document under review to make
sure that all reviews are covered completely.
Activity Purpose
And we also need to preserve the implementation and validation of the test case,
which takes lots of time from the test engineers.
Walkthrough process
includes overview, little
Inspection processes or no preparation, little
Process include overview, or no preparation
Structure preparation, inspection, examination (actual
and rework and follow up. walkthrough meeting),
and rework and follow
up.