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.
Software Testing defines a set of procedures and methods that check whether the
actual software product matches with expected requirements, thereby ensuring
that the product is Defect free. There are a set of procedures that needs to be in
mind while testing the software manually or by using automated procedures. The
main purpose of software testing is to identify errors, deficiencies, or missing
requirements with respect to actual requirements. Software Testing is Important
because if there are any bugs or errors in the software, they can be identified
early and can be solved before the delivery of the software product. The article
focuses on discussing the difference between bug, defect, error, fault, and failure.
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.
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
What do you mean by 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:
Invalid Valid
Invalid
(min- (min, min + 1, nominal, max – 1,
(max + 1)
1) max)
Valid Test cases: Valid test cases for the above can be any value entered greater
than 17 and less than 57.
1 ≤ Month≤12
1 ≤ Day ≤31
1900 ≤ Year ≤ 2000
Design Boundary Value Test Cases.
Solution: Taking the year as a Single Fault Assumption i.e. year will be having
values varying from 1900 to 2000 and others will have nominal values.
Taking Day as Single Fault Assumption i.e. Day will be having values varying
from 1 to 31 and others will have nominal values.
Taking Month as Single Fault Assumption i.e. Month will be having values
varying from 1 to 12 and others will have nominal values.
4 × 3 + 1 =13
2. Equivalence Partitioning
In this input data are divided into different equivalence data classes.
It is applied when there is a range of input values.
Example: Below is the example to combine Equivalence Partitioning and
Boundary Value.
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.
1. Node
2. Edge
3. Decision Node
4. Junction node
Node
Nodes in the control flow graph are used to create a path of procedures. Basically, it
represents the sequence of procedures which procedure is next to come so, the tester
can determine the sequence of occurrence of procedures.
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
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
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.
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.
Like decision coverage, it also uses a control flow graph to calculate the number of
branches.
There are several methods to calculate Branch coverage, but pathfinding is the most
common method.
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.
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."
=2
No 3,7 A1-B3-5-D7
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= -1 Path = 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).
Make associations for the code:
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).
o (1, (2, t), x), (1, (2, f), x)- This association is made with statement 1 (read x;)
and statement 2 (If(x>0)) where x is defined at line number 1, and it is used at
line number 2 so, x is the variable.
Statement 2 is logical, and it can be true or false that's why the association is
defined in two ways; one is (1, (2, t), x) for true and another is (1, (2, f), x) for
false.
o (1, 3, x)- This association is made with statement 1 (read x;) and statement 3
(a= x+1) where x is defined in statement 1 and used in statement 3. It is a
computation use.
o (1, (4, t), x), (1, (4, f), x)- This association is made with statement 1 (read x;)
and statement 4 (If(x<=0)) where x is defined at line number 1 and it is used at
line number 4 so x is the variable. Statement 4 is logical, and it can be true or
false that's why the association is defined in two ways one is (1, (4, t), x) for
true and another is (1, (4, f), x) for false.
o (1, (5, t), x), (1, (5, f), x)- This association is made with statement 1 (read x;)
and statement 5 (if (x<1)) where x is defined at line number 1, and it is used at
line number 5, so x is the variable.
Statement 5 is logical, and it can be true or false that's why the association is
defined in two ways; one is (1, (5, t), x) for true and another is (1, (5, f), x) for
false.
o (1, 6, x)- This association is made with statement 1 (read x;) and statement 6
(x=x+1). x is defined in statement 1 and used in statement 6. It is a
computation use.
o (1, 7, x)- This association is made with statement 1 (read x) and statement 7
(a=x+1). x is defined in statement 1 and used in statement 7 when statement 5
is false. It is a computation use.
o (6, (5, f) x), (6, (5, t) x)- This association is made with statement 6 (x=x+1;)
and statement 5 if (x<1) because x is defined in statement 6 and used in
statement 5. Statement 5 is logical, and it can be true or false that's why the
association is defined in two ways one is (6, (5, f) x) for true and another is (6,
(5, t) x) for false. It is a predicted use.
o (6, 6, x)- This association is made with statement 6 which is using the value of
variable x and then defining the new value of x.
x=x+1
x= (-1+1)
Statement 6 is using the value of variable x that is ?1 and then defining new
value of x [x= (-1+1) = 0] that is 0.
o (3, 8, a)- This association is made with statement 3(a= x+1) and statement 8
where variable a is defined in statement 3 and used in statement 8.
o (7, 8, a)- This association is made with statement 7(a=x+1) and statement 8
where variable a is defined in statement 7 and used in statement 8.
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)
If the value of a variable is used to compute a value for output or for defining another
variable.
Levels of 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
Inspections
Reviews
Walkthroughs
Desk-checking
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
Validation Testing is known as Dynamic Testing in which we examine whether
we have developed the product right or not and also about the business needs of
the client. Here are some of the activities that are involved in Validation.
Testing levels are the procedure for finding the missing areas and avoiding
overlapping and repetition between the development life cycle stages. We have
already seen the various phases such as Requirement collection, designing, coding
testing, deployment, and maintenance of SDLC (Software Development Life
Cycle).
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.
The levels of software testing involve the different methodologies, which can be used
while we are performing the software testing.
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 the first level of software testing, which is used to test if
software modules are satisfying the given requirement or not.
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.
The second level of software testing is the integration testing. The integration
testing process comes after unit testing.
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.
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.
Level3: System Testing
The third level of software testing is system testing, which is used to test the
software's functional and non-functional requirements.
The last and fourth level of software testing is acceptance testing, which is
used to evaluate whether a specification or the requirements are met as per its
delivery.
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.
Alpha test is a preliminary software field test carried out by a team of users to find out
the bugs that were not found previously by other tests.
Alpha testing is to simulate a real user environment by carrying out tasks and
operations that actual user might perform.
Alpha testing implies a meeting with a software vendor and client to ensure that the
developers appropriately meet the client's requirements in terms of the performance,
functionality, and durability of the software.
Alpha testing needs lab environment, and usually, the testers are an internal employee
of the organization. This testing is called alpha because it is done early on, near the
end of the software development, but before beta testing.
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.
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 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.
Select all test cases: In this technique, all the test cases are selected from the
already existing test suite. It is the most simple and safest technique but not
much efficient.
Select test cases randomly: In this technique, test cases are selected randomly
from the existing test-suite but it is only useful if all the test cases are equally
good in their fault detection capability which is very rare. Hence, it is not used
in most of the cases.
Select modification traversing test cases: In this technique, only those test
cases are selected which covers and tests the modified portions of the source
code the parts which are affected by these modifications.
Select higher priority test cases: In this technique, priority codes are assigned
to each test case of the test suite based upon their bug detection capability,
customer requirements, etc. After assigning the priority codes, test cases with
highest priorities are selected for the process of regression testing.
Test case with highest priority has highest rank. For example, test case with
priority code 2 is less important than test case with priority code 1.
Tools for regression testing: In regression testing, we generally select the test
cases from the existing test suite itself and hence, we need not to compute their
expected output and it can be easily automated due to this reason. Automating the
process of regression testing will be very much effective and time saving.
Most commonly used tools for regression testing are:
Selenium
WATIR (Web Application Testing In Ruby)
QTP (Quick Test Professional)
RFT (Rational Functional Tester)
Winrunner
Silktest
It ensures that no new bugs has been introduced after adding new
functionalities to the system.
As most of the test cases used in Regression Testing are selected from the
existing test suite and we already know their expected outputs. Hence, it can be
easily automated by the automated tools.
It helps to maintain the quality of the source code.
It can be time and resource consuming if automated tools are not used.
It is required even after very small changes in the code.
Stress Testing: Stress testing is a type of software testing that verifies the stability
and reliability of the system. This test particularly determines the system’s
robustness and error handling under extremely heavy load conditions.
Load varies from lowest to highest The load is directly changed from the
8.
limit uniformly. lowest to the highest(extreme) point.
What is Debugging?
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:
2. LLDB
3. Radare2
5. Valgrind
6. WinDBg
8. Eclipse debugger
Advantages of Debugging
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 ensures that the software is working fine as per the
expectations and plans.
Disadvantages of Debugging
It can be stressful for developers if they are working hard to find bugs or
errors.
In some cases, Debugging may result in the introduction of new bugs in the
software.