unit_2_testing_
unit_2_testing_
Testing methodologies
Black-Box Testing
The technique of testing without having any knowledge of the interior workings of
the application is called black-box testing. The tester is oblivious to the system
architecture and does not have access to the source code. Typically, while
performing a black-box test, a tester will interact with the system's user interface
by providing inputs and examining outputs without knowing how and where the
inputs are worked upon.
The following table lists the advantages and disadvantages of black-box testing.
Advantages Disadvantages
Well suited and efficient for large code segments. Limited coverage, since only a
selected number of test scenarios
is actually performed.
Clearly separates user's perspective from the Blind coverage, since the tester
developer's perspective through visibly defined cannot target specific code
roles. segments or errorprone areas.
Large numbers of moderately skilled testers can The test cases are difficult to
test the application with no knowledge of design.
implementation, programming language, or
operating systems.
White-Box Testing
White-box testing is the detailed investigation of internal logic and structure of the
code. White-box testing is also called glass testing or open-box testing. In
order to perform white-box testing on an application, a tester needs to know the
internal workings of the code.
The tester needs to have a look inside the source code and find out which
unit/chunk of the code is behaving inappropriately.
The following table lists the advantages and disadvantages of white-box testing.
Advantages Disadvantages
As the tester has knowledge of the Due to the fact that a skilled tester is
source code, it becomes very easy to find needed to perform white-box testing, the
out which type of data can help in testing costs are increased.
the application effectively.
Extra lines of code can be removed which It is difficult to maintain white-box testing,
can bring in hidden defects. as it requires specialized tools like code
analyzers and debugging tools.
White box testing techniques analyze the internal structures the used data
structures, internal design, code structure and the working of the software rather
than just the functionality as in black box testing. It is also called glass box testing
or clear box testing or structural testing.
Working process of white box testing:
Input: Requirements, Functional specifications, design documents, source
code.
Processing: Performing risk analysis for guiding through the entire process.
Proper test planning: Designing test cases so as to cover entire code.
Execute rinse-repeat until error-free software is reached. Also, the results are
communicated.
Output: Preparing final report of the entire testing process.
Testing techniques:
Statement coverage: In this technique, the aim is to traverse all statement
at least once. Hence, each line of code is tested. In case of a flowchart, every
node must be traversed at least once. Since all lines of code are covered, helps
in pointing out faulty code.
Statement Coverage is a white box testing technique in which all the executable
statements in the source code are executed at least once. It is used for calculation
of the number of statements in source code which have been executed. The main
purpose of Statement Coverage is to cover all the possible paths, lines and
statements in source code.
Statement coverage is used to derive scenario based upon the structure of the code
under test.
In White Box Testing, the tester is concentrating on how the software works. In
other words, the tester will be concentrating on the internal working of source code
concerning control flow graphs or flow charts.
Generally in any software, if we look at the source code, there will be a wide variety
of elements like operators, functions, looping, exceptional handlers, etc. Based on
the input to the program, some of the code statements may not be executed. The
goal of Statement coverage is to cover all the possible path’s, line, and statement in
the code.
The statements marked in yellow color are those which are executed as per the
scenario
Scenario 2:
If A = -3, B = -9
The statements marked in yellow color are those which are executed as per the
scenario.
But overall if you see, all the statements are being covered by 2 nd scenario’s
considered. So we can conclude that overall statement coverage is 100%.
What is covered by Statement Coverage?
1. Unused Statements
2. Dead Code
3. Unused Branches
4. Missing Statements
Decision Coverage
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.
Demo(int a) {
If (a> 5)
a=a*3
Print (a)
}
Scenario 1:Value of a is 2
The code highlighted in yellow will be executed. Here the “No” outcome of the
decision If (a>5) is checked.
Scenario 2: Value of a is 6
The code highlighted in yellow will be executed. Here the “Yes” outcome of the
decision If (a>5) is checked.
1 2 2 50%
2 6 18 50%
Branch Coverge: In this technique, test cases are designed so that each
branch from all decision points are traversed at least once. In a flowchart, all
edges must be traversed at least once.
4 test cases required such that all branches of all decisions are covered, i.e, all
Branch Coverage is a white box testing method .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.
Demo(int a) {
If (a> 5)
a=a*3
Print (a)
}
1 2 2 50% 33%
2 6 18 50% 67%
Condition coverage does not give a guarantee about full decision coverage.
Example:
TT
FF
TF
FT
X=3
(x<y) TRUE
Y=4
Condition Coverage is ¼ = 25%
A=3
(a>b) FALSE
B=4
Loop Testing is defined as a software testing type, that completely focuses on the
validity of the loop constructs. It is one of the parts of Control Structure Testing
(path testing, data validation testing, condition testing).
Loop testing is a White box testing. This technique is used to test loops in the
program.
Simple loop
Nested loop
Concatenated loop
Unstructured loop
while(condition 2)
{
statement(s);
}
}
3..Concatenated Loop Testing:
Testing performed in a concatenated loop is known as Concatenated loop
testing. It is performed on the concatenated loops. Concatenated loops are loops
after the loop. It is a series of loops. Difference between nested and
concatenated is that in nested loop is inside the loop but here loop is after the
loop.
Example:
while(condition 1)
{ statement(s); }
while(condition 2)
{ statement(s); }
The main focus of Black Box Testing is on the functionality of the system
as a whole. The term ‘Behavioral Testing’ is also used for Black Box Testing.
A majority of the applications are tested using the Black Box method. We need to
cover the majority of test cases so that most of the bugs will get discovered by the
Black-Box method.
This testing occurs throughout the Software Development and Testing Life Cycle i.e
in Unit, Integration, System, Acceptance, and Regression Testing stages.
This can be either Functional or Non-Functional.
For example, when we test a Dropdown list, we click on it and verify if it expands
and all the expected values are showing in the list.
Few major types of Functional Testing are:
Smoke Testing
Sanity Testing
Integration Testing
System Testing
Regression Testing
User Acceptance Testing
#2) Non-Functional Testing
These are required to be test and improve the quality and performance of the
application.
Unit Testing:
Unit testing is a type of software testing that focuses on individual units or
components of a software system.
The purpose of unit testing is to validate that each unit of the software
works as intended and meets the requirements.
Unit testing is typically performed by developers, and it is performed early
in the development process before the code is integrated and tested as a
whole system.
Code coverage is an important part of unit testing where the test cases need
to exist to cover the below three:
i)Line coverage
ii) Code path coverage
iii) Method coverage
Smoke Testing:
This type of testing is performed before the actual system testing to check if
the critical functionalities are working fine in order to carry out further
extensive testing.
This, in turn, saves time installing the new build again and avoids further
testing if the critical functionalities fail to work. This is a generalized way of
testing the application.
Sanity Testing:
It is a type of testing where only a specific functionality or a bug which is
fixed is tested to check whether the functionality is working fine and see if
there are no other issues due to the changes in the related components. It is
a specific way of testing the application.
Subset of regression testing
Regression Tests: Testing performed to ensure that adding new code,
enhancements, fixing of bugs is not breaking the existing functionality or causing
any instability and still works according to the specifications.
Regression tests need not be as extensive as the actual functional tests but should
ensure just the amount of coverage to certify that the functionality is stable.
Integration Tests:
Integration testing is the process of testing the interface between two
software units or modules.
It focuses on determining the correctness of the interface.
The purpose of integration testing is to expose faults in the interaction
between integrated units.
Once all the modules have been unit-tested, integration testing is
performed.
Integration testing is a software testing technique that focuses on verifying
the interactions and data exchange between different components or
modules of a software application.
The goal of integration testing is to identify any problems or bugs that arise
when different components are combined and interact with each other.
System testing is a testing that is performed on a complete system to verify if it
works as expected once all the modules or components are integrated.
End to end testing is performed to verify the functionality of the product. This
testing is performed only when system integration testing is complete including
both the functional & non-functional requirements.
What is Non-Functional Testing?
There are some aspects which are complex such as the performance of an
application etc and this testing checks the Quality of the software to be tested.
Quality majorly depends on time, accuracy, stability, correctness and durability of a
product under various adverse circumstances.
1) Load Testing:
An application which is expected to handle a particular workload is tested for
its response time in a real environment depicting a particular workload.
It is tested for its ability to function correctly in a stipulated time and is able
to handle the load.
2) Stress Testing:
In Stress testing, the application is stressed with an extra workload to check if
it works efficiently and is able to handle the stress as per the requirement.
Example: Consider a website which is tested to check its behavior when the
user accesses is at its peak. There could be a situation where the workload
crosses beyond the specification. In this case, the website may fail, slow
down or even crash.
Stress testing is to check these situations using automation tools to create a
real-time situation of workload and find the defects.
3) Volume Testing:
Under Volume testing the application’s ability to handle data in the volume is
tested by providing a real-time environment. The application is tested for its
correctness and reliability under adverse conditions.
4) Endurance Testing:
In Endurance testing the durability of the software is tested with a repeated
and consistent flow of load in a scalable pattern. It checks the endurance
power of the software when loaded with a consistent workload.
All these testing types are used to make the software work bug-free and
crash free under any real time situation by addressing the issues and finding
solutions accordingly for a quality product.
Usability Testing:
In this type of testing, the User Interface is tested for its ease of use and see
how user-friendly it is.
Security Testing:
Security Testing is to check how secure the software is regarding data over
the network from malicious attacks.
The key areas to be tested in this testing include authorization,
authentication of users and their access to data based on roles such as
admin, moderator, composer, and user level.
Equivalence Partitioning
Boundary Value Analysis
Decision Table Testing
State Transition Testing
Error Guessing
Graph-Based Testing Methods
Comparison Testing
#1) Equivalence Partitioning
This technique is also known as Equivalence Class Partitioning (ECP). In this
technique, input values to the system or application are divided into different
classes or groups based on its similarity in the outcome.
Hence, instead of using each and every input value, we can now use any one value
from the group/class to test the outcome. This way, we can maintain test coverage
while we can reduce the amount of rework and most importantly the time spent.
For Example:
As present in the above image, the “AGE” text field accepts only numbers from 18
to 60. There will be three sets of classes or groups.
We have thus reduced the test cases to only 3 test cases based on the formed
classes thereby covering all the possibilities. So, testing with any one value from
each set of the class is sufficient to test the above scenario.
Example-2:
Let us consider an example of any college admission process. There is a college
that gives admissions to students based upon their percentage.
Consider percentage field that will accept percentage only between 50 to 90 %,
more and even less than not be accepted, and application will redirect user to an
error page. If percentage entered by user is less than 50 %or more than 90 %, that
equivalence partitioning method will show an invalid percentage. If percentage
entered is between 50 to 90 %, then equivalence partitioning method will show
valid percentage.
For Example:
If we want to test a field where values from 1 to 100 should be accepted, then we
choose the boundary values: 1-1, 1, 1+1, 100-1, 100, and 100+1. Instead of using
all the values from 1 to 100, we just use 0, 1, 2, 99, 100, and 101.
If
{
(Condition = True)
then action1 ;
}
else action2; /*(condition = False)*/
Then a tester will identify two outputs (action1 and action2) for two conditions (True
and False). So based on the probable scenarios a Decision table is carved to
prepare a set of test cases.
For Example:
Take an example of XYZ bank that provides an interest rate for the Male senior
citizen as 10% and 9% for the rest of the people.
In this example condition, C1 has two values as true and false, C2 also has two
values as true and false. The total number of possible combinations would then be
four. This way we can derive test cases using a decision table.
State Transition Testing is a technique that is used to test the different states of the
system under test.
The state of the system changes depending upon the conditions or events. The
events trigger states which become scenarios and a tester needs to test them.
A systematic state transition diagram gives a clear view of the state changes but it
is effective for simpler applications. More complex projects may lead to more
complex transition diagrams thereby making it less effective.
For Example:
LET’S START!!
Key – Always go from Effect to Cause (left to right). That means, to get
effect “E”, what causes should be true.
In this example, let’s start with Effect E1.
So as per the above diagram, for E1 to be true the condition is (C1 C2) C3
The circle in the middle is just an interpretation of the middle point to make the
graph less messy.
There is a third condition where C1 and C2 are mutually exclusive. So the final
graph for effect E1 to be true is shown below:
This completes the Cause and Effect graph for the above situation.
Now let’s move to draw the Decision table based on the above graph.
The Key is the same. Go from bottom to top which means traverse from Effect to
Cause.
Start with Effect E1. For E1 to be true, the condition is (C1 C2) C3.
Here we are representing True as 1 and False as 0
So it is completed. Let’s complete the graph by adding 0 in the blank column and
include the test case identifier.
This is a higher level testing such as functional This type of testing is performed at a
testing. lower level of testing such as Unit
Testing, Integration Testing.
Black box testing requires Requirement White Box testing requires Design
specification to test. documents with data flow diagrams,
flowcharts etc.
Black Box Testing White Box Testing
Black box testing is done by the testers. White box testing is done by Developers
or testers with programming knowledge.