Se Unit Iv
Se Unit Iv
Testing Fundamentals- Error, Fault & Failure, Black Box Testing- Equivalence
Partitioning, Boundary value Analysis, White Box Testing- Control flow-based
Testing, Data flow-based Testing, Testing Strategies- Verification & Validation, Unit
Testing, Integration Testing, System Testing, Acceptance Testing, Deriving Test Cases,
Alpha and Beta Testing, Regression Testing, Performance Testing, Stress Testing,
Debugging.
What is a Bug?
A bug refers to defects which means that the software product or the application
is not working as per the adhered requirements set. When we have any type of
logical error, it causes our code to break, which results in a bug. It is now that
the Automation/ Manual Test Engineers describe this situation as a bug.
A bug once detected can be reproduced with the help of standard bug-
reporting templates.
Major bugs are treated as prioritized and urgent especially when there is a
risk of user dissatisfaction.
The most common type of bug is a crash.
Typos are also bugs that seem tiny but are capable of creating disastrous
results.
What is a Defect?
A defect refers to a situation when the application is not working as per the
requirement and the actual and expected result of the application or software are
not in sync with each other.
The defect is an issue in application coding that can affect the whole
program.
It represents the efficiency and inability of the application to meet the criteria
and prevent the software from performing the desired work.
The defect can arise when a developer makes major or minor mistakes during
the development phase.
What is an Error?
Error is a situation that happens when the Development team or the developer
fails to understand a requirement definition and hence that misunderstanding gets
translated into buggy code. This situation is referred to as an Error and is mainly
a term coined by the developers.
Errors are generated due to wrong logic, syntax, or loop that can impact the
end-user experience.
It is calculated by differentiating between the expected results and the actual
results.
It raises due to several reasons like design issues, coding issues, or system
specification issues and leads to issues in the application.
What is a Fault?
Sometimes due to certain factors such as Lack of resources or not following
proper steps Fault occurs in software which means that the logic was not
incorporated to handle the errors in the application. This is an undesirable
situation, but it mainly happens due to invalid documented steps or a lack of data
definitions.
It is an unintended behavior by an application program.
It causes a warning in the program.
If a fault is left untreated it may lead to failure in the working of the deployed
code.
A minor fault in some cases may lead to high-end error.
There are several ways to prevent faults like adopting programming
techniques, development methodologies, peer review, and code analysis.
What is a Failure?
Failure is the accumulation of several defects that ultimately lead to Software
failure and results in the loss of information in critical modules thereby making
the system unresponsive. Generally, such situations happen very rarely because
before releasing a product all possible scenarios and test cases for the code are
simulated. Failure is detected by end-users once they face a particular issue in
the software.
Failure can happen due to human errors or can also be caused intentionally in
the system by an individual.
It is a term that comes after the production stage of the software.
It can be identified in the application when the defective part is executed.
A simple diagram depicting Bug vs Defect vs Fault vs Failure:
Software Testing
Boundary Value Analysis is based on testing the boundary values of valid and
invalid partitions. The behavior at the edge of the equivalence partition is more
likely to be incorrect than the behavior within the partition, so boundaries are an
area where testing is likely to yield defects.
It checks for the input values near the boundary that have a higher chance of
error. Every partition has its maximum and minimum values and these maximum
and minimum values are the boundary values of a partition.
Note:
A boundary value for a valid partition is a valid boundary value.
A boundary value for an invalid partition is an invalid boundary value.
For each variable we check-
Minimum value.
Just above the minimum.
Nominal Value.
Just below Max value.
Max value.
Example: Consider a system that accepts ages from 18 to 56.
Invalid Valid
Invalid
(min- (min, min + 1, nominal, max – 1,
(max + 1)
1) max)
Taking Month as Single Fault Assumption i.e. Month will be having values
varying from 1 to 12 and others will have nominal values.
2. Equivalence Partitioning
Enter value 0 to 5
1 Not accepted
character
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.
We can see below in example the first node represent the start procedure and the next
procedure is to assign the value of n after assigning the value there is decision node to
decide next node of procedure as per the value of n if it is 18 or more than 18 so
Eligible procedure will execute otherwise if it is less than 18 Not Eligible procedure
executes. The next node is the junction node, and the last node is stop node to stop the
procedure.
Edge
Edge in control flow graph is used to link the direction of nodes.
We can see below in example all arrows are used to link the nodes in an appropriate
direction.
Decision node
Decision node in the control flow graph is used to decide next node of procedure as
per the value.
We can see below in example decision node decide next node of procedure as per the
value of n if it is 18 or more than 18 so Eligible procedure will execute otherwise if it
is less than 18, Not Eligible procedure executes.
Junction node
Junction node in control flow graph is the point where at least three links meet.
Example
The above example shows eligibility criteria of age for voting where if age is 18 or
more than 18 so print message "You are eligible for voting" if it is less than 18 then
print "You are not eligible for voting."
Program for this scenario is written above, and the control flow graph is designed for
the testing purpose.
In the control flow graph, start, age, eligible, not eligible and stop are the nodes,
n>=18 is a decision node to decide which part (if or else) will execute as per the given
value. Connectivity of the eligible node and not eligible node is there on the stop
node.
Test cases are designed through the flow graph of the programs to determine the
execution path is correct or not. All nodes, junction, edges, and decision are the
essential parts to design test cases.
However, branch coverage technique and decision coverage technique are very
similar, but there is a key difference between the two. Decision coverage technique
covers all branches of each decision point whereas branch testing covers all branches
of every decision point of the code.
In other words, branch coverage follows decision point and branch coverage
edges. Many different metrics can be used to find branch coverage and decision
coverage, but some of the most basic metrics are: finding the percentage of
program and paths of execution during the execution of the program.
In this method, the number of paths of executed branches is used to calculate Branch
coverage. Branch coverage technique can be used as the alternative of decision
coverage. Somewhere, it is not defined as an individual technique, but it is distinct
from decision coverage and essential to test all branches of the control flow graph.
1. Read X
2. Read Y
3. IF X+Y > 100 THEN
4. Print "Large"
5. ENDIF
6. If X + Y<100 THEN
7. Print "Small"
8. ENDIF
This is the basic code structure where we took two variables X and Y and two
conditions. If the first condition is true, then print "Large" and if it is false, then go to
the next condition. If the second condition is true, then print "Small."
Yes 1, 2, 4, 5, 6, 8 A1-B2-C4-D6-E8 2
No 3,7 A1-B3-5-D7
Cyclomatic Complexity = Total number of closed regions in the control flow graph + 1
Method-02:
Cyclomatic Complexity = E – N + 2
Here-
E = Total number of edges in the control flow graph
N = Total number of nodes in the control flow graph
Method-03:
Cyclomatic Complexity = P + 1
Here,
P = Total number of predicate nodes contained in the control flow graph
Problem-01:
Solution-
We draw the following control flow graph for the given code-
Using the above control flow graph, the cyclomatic complexity may be calculated as-
Method-01:
Cyclomatic Complexity
= Total number of closed regions in the control flow graph + 1
=2+1
=3
Method-02:
Cyclomatic Complexity
=E–N+2
=8–7+2
=3
Method-03:
Cyclomatic Complexity
=P+1
=2+1
=3
Decision Coverage Testing
Decision Coverage is a white box testing technique which reports the true or false outcomes
of each boolean expression of the source code. The goal of decision coverage testing is to
cover and validate all the accessible source code by checking and ensuring that each branch of
every possible decision point is executed at least once.
In this coverage, expressions can sometimes get complicated. Therefore, it is very hard to
achieve 100% coverage. That’s why there are many different methods of reporting this
metric. All these methods focus on covering the most important combinations. It is very much
similar to decision coverage, but it offers better sensitivity to control flow.
Statement coverage is one of the widely used software testing. It comes under white
box testing.
Statement coverage technique is used to design white box test cases. This technique
involves execution of all statements of the source code at least once. It is used to
calculate the total number of executed statements in the source code out of total
statements present in the source code.
Statement coverage derives scenario of test cases under the white box testing process
which is based upon the structure of the code.
In white box testing, concentration of the tester is on the working of internal source
code and flow chart or flow graph of the code.
Data flow testing is a group of testing strategies to examine the control flow of
programs in order to explore the sequence of variables according to the sequence of
events. It mainly focuses on the points at which values assigned to the variables and
the point at which these values are used by concentrating on both points, data flow
can be tested.
Data flow testing uses the control flow graph to detect illogical things that can
interrupt the flow of data. Anomalies in the flow of data are detected at the time of
associations between values and variables due to:
In this code, we have a total 8 statements, and we will choose a path which covers all
the 8 statements. As it is evident in the code, we cannot cover all the statements in a
single path because if statement 2 is true then statements 4, 5, 6, 7 not covered, and if
statement 4 is true then statement 2 and 3 are not covered.
1. x= 1Path - 1, 2, 3, 8
Output = 2
When we set value of x as 1 first it come on step 1 to read and assign the value of x
(we took 1 in path) then come on statement 2 (x>0 (we took 2 in path)) which is true
and it comes on statement 3 (a= x+1 (we took 3 in path)) at last it comes on statement
8 to print the value of x (output is 2).
2. Set x= -1Path = 1, 2, 4, 5, 6, 5, 6, 5, 7, 8
Output = 2
When we set the value of x as ?1 then first, it comes on step 1 to read and assign the
value of x (we took 1 in the path) then come on step number 2 which is false because
x is not greater than 0 (x>0 and their x=-1). Due to false condition, it will not come on
statement 3 and directly jump on statement 4 (we took 4 in path) and 4 is true (x<=0
and their x is less than 0) then come on statement 5 (x<1 (we took 5 in path)) which is
also true so it will come on statement 6 (x=x+1 (we took 6 in path)) and here x is
incremented by 1.
So,
x=-1+1
x=0
There is value of x become 0. Now it goes to statement 5(x<1 (we took 5 in path))
with value 0 and 0 is less than 1 so, it is true. Come on statement 6 (x=x+1 (we took 6
in path))
x=x+1
x= 0+1
x=1
There x has become 1 and again goes to statement 5 (x<1 (we took 5 in path)) and
now 1 is not less than 1 so, condition is false and it will come to else part means
statement 7 (a=x+1 where the value of x is 1) and assign the value to a (a=2). At last,
it come on statement 8 and print the value (Output is 2).
Associations
In associations we list down all the definitions with all of its uses.
(1, (2, f), x), (1, (2, t), x), (1, 3, x), (1, (4, t), x), (1, (4, f), x), (1, (5, t), x), (1, (5, f), x),
(1, 6, x), (1, 7, x), (6,(5, f)x), (6,(5,t)x), (6, 6, x), (3, 8, a), (7, 8, a).
So, these are the all association which contain definition, Predicate use (p-use),
Computation use (c-use)
(1, (2, f), x), (1, (2, t), x), (1, 3, x), (1, (4, t), x), (1, (4, f), x), (1, (5, t), x), (1, (5, f), x),
(1, 6, x), (1, 7, x), (6,(5, f)x), (6,(5,t)x), (6, 6, x), (3, 8, a), (7, 8, a), (3, 8, a), (7, 8, a)
Definition
Definition of a variable is the occurrence of a variable when the value is bound to the
variable. In the above code, the value gets bound in the first statement and then start
to flow.
(1, (2, f), x), (6, (5, f) x), (3, 8, a), (7, 8, a).
These are Computation use because the value of x is used to compute and value of a
is used for output.
(1, 3, x), (1, 6, x), (1, 7, x), (6, 6, x), (6, 7, x), (3, 8, a), (7, 8, a).
(1, 3, x), (1, 6, x), (1, 7, x), (6, 6, x), (6, 7, x), (3, 8, a), (7, 8, a).
(1, (2, f), x), (1, (2, t), x), (1, (4, t), x), (1, (4, f), x), (1, (5, t), x), (1, (5, f), x), (6, (5, f),
x), (6, (5, t), x), (3, 8, a), (7, 8, a).
After collecting these groups, (By examining each point whether the variable is used
at least once or not) tester can see all statements and variables are used. The
statements and variables which are not used but exist in the code, get eliminated from
the code.
Levels of Testing
In this section, we are going to understand the various levels of
software testing.
Verification
Verification is the process of checking that software achieves its goal without any
bugs. It is the process to ensure whether the product that is developed is right or
not. It verifies whether the developed product fulfills the requirements that we
have. Verification is simply known as Static Testing.
Static Testing
Validation
Validation is the process of checking whether the software product is up to the
mark or in other words product has high-level requirements. It is the process of
checking the validation of the product i.e. it checks what we are developing is the
right product. it is a validation of actual and expected products. Validation is
simply known as Dynamic Testing.
Dynamic Testing
In order to test any application, we need to go through all the above phases of SDLC.
Like SDLC, we have multiple levels of testing, which help us maintain the quality of
the software.
In software testing, we have four different levels of testing, which are as discussed
below:
1. Unit Testing
2. Integration Testing
3. System Testing
4. Acceptance Testing
As we can see in the above image that all of these testing levels have a specific
objective which specifies the value to the software development lifecycle.
Unit testing is also the first level of functional testing. The primary purpose of
executing unit testing is to validate unit components with their performance.
Unit testing will help the test engineer and developers in order to understand the base
of code that makes them able to change defect causing code quickly. The developers
implement the unit.
It is mainly used to test the data flow from one module or component to other
modules.
In integration testing, the test engineer tests the units or separate components or
modules of the software in a group.
The primary purpose of executing the integration testing is to identify the defects at
the interaction between integrated components or units.
When each component or module works separately, we need to check the data flow
between the dependent modules, and this process is known as integration testing.
We only go for the integration testing when the functional testing has been completed
successfully on each application module.
In simple words, we can say that integration testing aims to evaluate the accuracy of
communication among all the modules.
In system testing, we will go through all the necessary modules of an application and
test if the end features or the end business works fine, and test the product as a
complete system.
In simple words, we can say that System testing is a sequence of different types of
tests to implement and examine the entire working of an integrated software computer
system against requirements.
The software has passed through three testing levels (Unit Testing, Integration
Testing, System Testing). Some minor errors can still be identified when the end-
user uses the system in the actual scenario.
In simple words, we can say that Acceptance testing is the squeezing of all the
testing processes that are previously done.
The acceptance testing is also known as User acceptance testing (UAT) and is done
by the customer before accepting the final product.
Usually, UAT is done by the domain expert (customer) for their satisfaction and
checks whether the application is working according to given business scenarios and
real-time scenarios.
Beta Testing is a type of acceptance testing; it is the final test before shipping a
product to the customers. Beta testing of a product is implemented by "real users "of
the software application in a "real environment." In this phase of testing, the software
is released to a limited number of end-users of the product to obtain feedback on the
product quality. It allows the real customers an opportunity to provide inputs into the
design, functionality, and usability of the product. These inputs are essential for the
success of the product. Beta testing reduces product failure risks and increases the
quality of the product through customer validation. Direct feedback from customers is
a significant advantage of beta testing. This testing helps to tests the software in a real
environment. The experiences of the previous users are forwarded back to the
developers who make final changes before releasing the software product.
2. Alpha testing performed at the Beta testing doesn't need any lab
developer's site; it always needs a environment or the testing environment; it is
testing environment or lab performed at a client's location or end-user
environment. of the product.
4. Alpha testing involves both white Beta testing uses only black-box testing.
box and black-box techniques.
5. Long execution cycles maybe require Only a few weeks are required for the
for alpha testing. execution of beta testing.
7. Alpha testing performed before the At the time of software product marketing.
launch of the product into the
market.
8. Alpha testing focuses on the Beta testing concentrates on the quality of
product's quality before going to beta the product, but gathers users input on the
testing. product and ensures that the product is ready
for real-time users.
9. Alpha testing performed nearly the Beta testing is a final test before shipping a
end of the software development. product to the customers.
10. Alpha testing is conducting in the Beta testing reversed of alpha testing.
presence of developers and the
absence of end-users.
Regression Testing
Regression Testing is the process of testing the modified parts of the code and the
parts that might get affected due to the modifications to ensure that no new errors
have been introduced in the software after the modifications have been made.
Regression means return of something and in the software field, it refers to the
return of a bug.
When to do regression testing?
When a new functionality is added to the system and the code has been
modified to absorb and integrate that functionality with the existing code.
When some defect has been identified in the software and the code is
debugged to fix it.
When the code is modified to optimize its working.
Process of Regression testing:
Firstly, whenever we make some changes to the source code for any reasons like
adding new functionality, optimization, etc. then our program when executed fails
in the previously designed test suite for obvious reasons. After the failure, the
source code is debugged in order to identify the bugs in the program. After
identification of the bugs in the source code, appropriate modifications are made.
Then appropriate test cases are selected from the already existing test suite which
covers all the modified and affected parts of the source code. We can add new test
cases if required. In the end regression testing is performed using the selected test
cases.
Load varies from lowest to highest The load is directly changed from the
8.
limit uniformly. lowest to the highest(extreme) point.
Debugging
What is Debugging?
Debugging is defined as the process of identifying errors or bugs in a
program and fixing the identified bugs. The process of debugging involves
the tracing of the program’s execution for the identification of the source of
the problem, analysis of the code to understand the cause of the error, and
modifying the code to fix the bug.
Strategies for Debugging
Some of the common strategies which are employed for purpose of
debugging are listed below.
Debugging Tools
Many tools have been used to identify and fix bugs; debugging tools are
software applications that are used to test and debug other software systems.
There are several open-source debugging tools on the market, such as DBX,
GDB, and others. Some examples are:
Advantages of Debugging
The advantages of Debugging are given below:
The identification of the bugs at an earlier stage helps in saving the time of
the developers.
This identification and fixing of bugs also save money in the long run.
This process of debugging helps in improving the code quality of the
software.
Debugging can result in better code optimization of the software/product.
This process ensures that the software is working fine as per the
expectations and plans.
Disadvantages of Debugging
Here are some Disadvantages associated with Debugging.