Unit 2
Unit 2
TYPES OF TESTING
Types of Testing
The categorization of software testing is a part of diverse testing
activities, such as test strategy, test deliverables, a defined test
objective, etc. And software testing is the execution of the software to
find defects.
The purpose of having a testing type is to confirm the AUT (Application
Under Test).
To start testing, we should have a requirement, application-ready,
necessary resources available. To maintain accountability, we should
assign a respective module to different test engineers.
The software testing mainly divided into two parts, which are as
follows:
1. Manual Testing
2. Automation Testing
What is Manual Testing?
Testing any software or an application according to the client's needs
without using any automation tool is known as manual testing.
In other words, we can say that it is a procedure of verification and
validation. Manual testing is used to verify the behavior of an
application or software in contradiction of requirements specification.
We do not require any precise knowledge of any testing tool to execute
the manual test cases. We can easily prepare the test document while
performing manual testing on any application.
Classification of Manual Testing:
In software testing, manual testing can be further classified into three
different types of testing, which are as follows:
1. Black Box Testing
2. White Box Testing
3. Grey Box Testing
Black Box Testing
Another type of manual testing is black-box testing. In this testing,
the test engineer will analyze the software against requirements,
identify the defects or bug, and sends it back to the development
team.
Then, the developers will fix those defects, do one round of White
box testing, and send it to the testing team.
Here, fixing the bugs means the defect is resolved, and the
particular feature is working according to the given requirement.
The main objective of implementing the black box testing is to
specify the business needs or the customer's requirements.
In other words, we can say that black box testing is a process of
checking the functionality of an application as per the customer
requirement. The source code is not visible in this testing; that's
why it is known as black-box testing.
Generic steps of black box testing
• The black box test is based on the specification of requirements, so it is
examined in the beginning.
• In the second step, the tester creates a positive test scenario and an
adverse test scenario by selecting valid and invalid input values to check
that the software is processing them correctly or incorrectly.
• In the third step, the tester develops various test cases such as decision
table, all pairs test, equivalent division, error estimation, cause-effect
graph, etc.
• The fourth phase includes the execution of all test cases.
• In the fifth step, the tester compares the expected output against the
actual output.
• In the sixth and final step, if there is any flaw in the software, then it is
cured and tested again.
Test procedure
In the above state transition table, we see that state S1 denotes first
login attempt. When the first attempt is invalid, the user will be
directed to the second attempt (state S2). If the second attempt is also
invalid, then the user will be directed to the third attempt (state S3).
Now if the third and last attempt is invalid, then the user will be
directed to the error page (state S5). But if the third attempt is valid,
then it will be directed to the homepage (state S4).
Let's see state transition table if third attempt is valid:
STATE LOGIN VALIDATION REDIRECTED
S1 First Attempt Invalid S2
S2 Second Attempt Invalid S3
S3 Third Attempt Valid S4
S4 Home Page
S5 Error Page
By using the above state transition table we can perform testing of any
software application. We can make a state transition table by
determining desired output, and then exercise the software system to
examine whether it is giving desired output or not.
4.Equivalence Partitioning Technique
• Equivalence partitioning is a technique of software testing in which
input data is divided into partitions of valid and invalid values, and it
is mandatory that all partitions must exhibit the same behavior. If a
condition of one partition is true, then the condition of another equal
partition must also be true, and if a condition of one partition is false,
then the condition of another equal partition must also be false.
• The principle of equivalence partitioning is, test cases should be
designed to cover each partition at least once. Each value of every
equal partition must exhibit the same behavior as other.
• 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.
Examples of Equivalence Partitioning technique:
Assume that there is a function of a software application that accepts a
particular number of digits, not greater and less than that particular
number. For example, an OTP number which contains only six digits,
less or more than six digits will not be accepted, and the application
will redirect the user to the error page.
1. OTP Number = 6 digits
• A function of the software application accepts a 10 digit mobile number.
2. Mobile number = 10 digits
• In both examples, we can see that there is a partition of two equally valid and invalid
partitions, on applying valid value such as OTP of six digits in the first example and mobile
number of 10 digits in the second example, both valid partitions behave same, i.e.
redirected to the next page.
• Another two partitions contain invalid values such as 5 or less than 5 and 7 or more than 7
digits in the first example and 9 or less than 9 and 11 or more than 11 digits in the second
example, and on applying these invalid values, both invalid partitions behave same, i.e.
redirected to the error page.
• We can see in the example, there are only three test cases for each example and that is also
the principal of equivalence partitioning which states that this method intended to reduce
the number of test cases.
Why Black-box testing is required ?
If A = -2, B = -7
print (int a, int b) {
int sum = a + b;
if (sum>0)
print ("This is a positive result")
else
print ("This is negative result")
}
• In scenario 2, we can see the value of sum will be -9 that is less than 0 and
as per the condition, result will be "This is a negative result." The
statements highlighted in yellow color are executed statements of this
scenario.
• To calculate statement coverage of the first scenario, take the total number
of statements that is 7 and the number of used statements that is 6.
Total number of statements = 7,
Number of executed statements = 6
Statement coverage = 6/7*100
= 600/7
= 85%
But, we can see all the statements are covered in both scenario and
we can consider that the overall statement coverage is 100%.
So, the statement coverage technique covers dead code, unused
code, and branches.
2. Condition Coverage: • Result:
Condition coverage is also known as • In order to ensure complete Condition
Predicate Coverage in which each one coverage criteria for the above
of the Boolean expression have been example, A, B and C should be
evaluated to both TRUE and FALSE evaluated at least once against "true"
Example: and "false".
if ((A || B) && C) • So, in our example, the 3 following
tests would be sufficient for 100%
{ Condition coverage testing.
<< Few Statements >> • A = true | B = not eval | C = false
} • A = false | B = true | C = true
else • A = false | B = false | C = not eval
{
<< Few Statements >>
}
3. Loop Testing:
is a type of software testing type that is performed to validate the loops. It is
one of the type of Control Structure Testing. Loop testing is a white box
testing technique and is used to test loops in the program.
Objectives of Loop Testing:
The objective of Loop Testing is:
• To fix the infinite loop repetition problem.
• To know the performance.
• To identify the loop initialization problems.
• To determine the uninitialized variables.
Types of Loop Testing:
1. Simple Loop Testing
2. Nested Loop Testing
3. Concatenated Loop Testing
4. Unstructured Loop Testing
https://www.geeksforgeeks.org/loop-software-testing/
4. Branch Coverage:
Branch Coverage is a white box testing method in which every
outcome from a code module(statement or loop) is tested. The
purpose of branch coverage is to ensure that each decision
condition from every branch is executed at least once. It helps to
measure fractions of independent code segments and to find out
sections having no branches.
For example, if the outcomes are binary, you need to test both True
and False outcomes.
Example:
Demo(int a) { Value of Decision Branch
Test Case Output
If (a> 5) A Coverage Coverage
1 2 2 50% 33%
a=a*3
2 6 18 50% 67%
Print (a)
}
The formula to calculate Branch Coverage:
5. Path Coverage:
Path coverage is concerned with linearly independent
paths through the code. Testers draw a control flow
diagram of the code, such as the example below.
In this example, there are several possible paths
through the code:
• 1, 2
• 1, 3, 4, 5, 6, 8
• 1, 3, 4, 7, 6, 8 etc.
In a path coverage approach, the tester writers unit
tests to execute as many as possible of the paths
through the program’s control flow. The objective is to
identify paths that are broken, redundant, or inefficient.
• Basis Path Testing in software engineering is a White Box Testing method in which test
cases are defined based on flows or logical paths that can be taken through the
program.
• The objective of basis path testing is to define the number of independent paths, so the
number of test cases needed can be defined explicitly to maximize test coverage.
• Basis path testing involves execution of all possible blocks in a program and achieves
maximum path coverage with the least number of test cases. It is a hybrid method of
branch testing and path testing methods
The guidelines for effectiveness of path testing are discussed below:
1) Path testing is based on control structure of the program for which flow graph is
prepared.
2) Path testing requires complete knowledge of the program’s structure.
3) Path testing is closer to the developer and used by him to test his module.
4) The effectiveness of path testing gets reduced with the increase in size of software
under test.
5) Choose enough paths in a program such that maximum logic coverage is achieved.
Control Flow Testing
• Control flow testing is a testing technique that comes under white box testing.
• The aim of this technique is to determine the execution order of statements or
instructions of the program through a control structure.
• The control structure of a program is used to develop a test case for the
program.
• In this technique, a particular part of a large program is selected by the tester to
set the testing path. It is mostly used in unit testing. Test cases represented by
the control graph of the program.
• Control Flow Graph is formed from the node, edge, decision node, junction
node to specify all possible execution path.
Notations used for Control Flow Graph
1. Node
2. Edge
3. Decision Node
4. Junction node
Node
• It represents one or more procedural statements.
• The nodes are denoted by a circle.
• These are numbered or labeled.
Edges or links
• They represent the flow of control in a program.
• This is denoted by an arrow on the edge.
• An edge must terminate at a node.
Decision node
• A node with more than one arrow leaving it is called a decision node.
Junction node
• A node with more than one arrow entering it is called a junction.
Regions
• Areas bounded by edges and nodes are called regions.
• When counting the regions, the area outside the graph is also
considered a region.
Example:
Diagram - control flow graph
public class VoteEligiblityAge{