Unit 3
Unit 3
Functional testing is a type of software testing in which the system is tested against the
functional requirements of the system. It is conducted to ensure that the requirements are
properly satisfied by the application. Functional testing verifies that each function of the
software application works in conformance with the requirement and specification. Boundary
Value Analysis(BVA) is one of the functional testings.
Boundary Value Analysis
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.
In simple terms boundary value Analysis is like testing the edge cases of our software where
most of the time it will get broke so it is important to do BVA before deploying the code.
There are many other test that are done if you wish to learn them all then you can join
our complete software testing course
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-
o Minimum value.
o Just above the minimum.
o Nominal Value.
o Just below Max value.
o Max value.
Example: Consider a system that accepts ages from 18 to 56.
Boundary Value Analysis(Age accepts 18 to 56)
Valid Test cases: Valid test cases for the above can be any value entered greater than 17 and
less than 57.
Enter the value- 18.
Enter the value- 19.
Enter the value- 37.
Enter the value- 55.
Enter the value- 56.
Invalid Testcases: When any value less than 18 and greater than 56 is entered.
Enter the value- 17.
Enter the value- 57.
Single Fault Assumption: When more than one variable for the same application is checked
then one can use a single fault assumption. Holding all but one variable to the extreme value
and allowing the remaining variable to take the extreme value. For n variable to be checked:
Maximum of 4n+1 test cases
Problem: Consider a Program for determining the Previous Date.
Input: Day, Month, Year with valid ranges as-
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.
Test Cases Month Day Year Output
Taking Day as Single Fault Assumption i.e. Day will be having values varying from 1 to 31
and others will have nominal values.
Test Case Month Day Year Output
Taking Month as Single Fault Assumption i.e. Month will be having values varying from 1 to
12 and others will have nominal values.
Test Case Month Day Year Output
For the n variable to be checked Maximum of 4n + 1 test case will be required. Therefore, for n
= 3, the maximum test cases are-
4 × 3 + 1 =13
The focus of BVA: BVA focuses on the input variable of the function. Let’s define two
variables X1 and X2, where X1 lies between a and b and X2 lies between c and d.
Showing legitimate domain
The idea and motivation behind BVA are that errors tend to occur near the extremes of the
variables. The defect on the boundary value can be the result of countless possibilities.
Typing of Languages: BVA is not suitable for free-form languages such as COBOL and
FORTRAN, These languages are known as weakly typed languages. This can be useful and
can cause bugs also.
PASCAL, ADA is the strongly typed language that requires all constants or variables defined
with an associated data type.
Limitation of Boundary Value Analysis:
It works well when the product is under test.
It cannot consider the nature of the functional dependencies of variables.
BVA is quite rudimentary.
Equivalence Partitioning
It is a type of black-box testing that can be applied to all levels of software testing . In this
technique, input data are divided into the equivalent partitions that can be used to derive test
cases-
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.
Consider a field that accepts a minimum of 6 characters and a maximum of 10 characters. Then
the partition of the test cases ranges 0 – 5, 6 – 10, 11 – 14.
Test Scenario Test Description Expected Outcome
Why Combine Equivalence Partitioning and Boundary Analysis Testing: Following are
some of the reasons why to combine the two approaches:
In this test cases are reduced into manageable chunks.
The effectiveness of the testing is not compromised on test cases.
Works well with a large number of variables.
1 1 6 2000 2-6-2000
Test Case ID Day MonthYear Expected Output
2 2 6 2000 3-6-2000
3 15 6 2000 16-6-2000
4 30 6 2000 1-7-2000
6 15 1 2000 16-1-2000
7 15 2 2000 16-2-2000
8 15 11 2000 16-11-2000
9 15 12 2000 16-12-2000
10 15 6 1800 16-6-1800
11 15 6 1801 16-6-1801
12 15 6 2047 16-6-2047
13 15 6 2048 16-6-2048
Test Cases:
Test Case ID Day MonthYear Expected Output
E1 15 4 2004 16-4-2004
E2 15 4 2003 16-4-2003
Test Case ID Day MonthYear Expected Output
E3 15 1 2004 16-1-2004
E4 15 1 2003 16-1-2003
E5 15 2 2004 16-2-2004
E6 15 2 2003 16-2-2003
E7 29 4 2004 30-4-2004
E8 29 4 2003 30-4-2003
E9 29 1 2004 30-1-2004
So from this problem it is clearly seen that equivalence class testing clearly checks for many
cases that boundary value did not considered like that of February which has 28-29 days, leap
year which lead to variation in number of days in February and many more. Hence the above
example proves that equivalence partitioning generates more efficient test cases that should be
considered during risk assessment.
To illustrate the approach of data flow testing, assume that each statement in the program is
assigned a unique statement number. For a statement number S-
If a statement is a loop or if condition then its DEF set is empty and the USE set is based on
the condition of statement s. Data Flow Testing uses the control flow graph to find the
situations that can interrupt the flow of the program. Reference or defined anomalies in the
flow of the data are detected at the time of associations between values and variables. These
anomalies are:
A variable is defined but not used or referenced,
A variable is used but never defined,
A variable is defined twice before it is used
Types of Data Flow Testing
1. Testing for All-Du-Paths: It Focuses on “All Definition-Use Paths. All-Du-Paths is an
acronym for “All Definition-Use Paths.” Using this technique, every possible path from a
variable’s definition to every usage point is tested.
2. All-Du-Path Predicate Node Testing: This technique focuses on predicate nodes, or
decision points, in the control flow graph.
3. All-Uses Testing: This type of testing checks every place a variable is used in the
application.
4. All-Defs Testing: This type of testing examines every place a variable is specified within
the application’s code.
5. Testing for All-P-Uses: All-P-Uses stands for “All Possible Uses.” Using this method,
every potential use of a variable is tested.
6. All-C-Uses Test: It stands for “All Computation Uses.” Testing every possible path where
a variable is used in calculations or computations is the main goal of this technique.
7. Testing for All-I-Uses: All-I-Uses stands for “All Input Uses.” With this method, every
path that uses a variable obtained from outside inputs is tested.
8. Testing for All-O-Uses: It stands for “All Output Uses.” Using this method, every path
where a variable has been used to produce output must be tested.
9. Testing of Definition-Use Pairs: It concentrates on particular pairs of definitions and uses
for variables.
10. Testing of Use-Definition Paths: This type of testing examines the routes that lead from a
variable’s point of use to its definition.
Advantages of Data Flow Testing:
Data Flow Testing is used to find the following issues-
To find a variable that is used but never defined,
To find a variable that is defined but never used,
To find a variable that is defined multiple times before it is use,
Deallocating a variable before it is used.
Disadvantages of Data Flow Testing
Time consuming and costly process
Requires knowledge of programming languages
Example:
1. read x, y;
2. if(x>y)
3. a = x+1
else
4. a = y-1
5. print a;
Control flow graph of above example:
x 1 2, 3
y 1 2, 4
a 3, 4 5
Conclusion
Data Flow Testing effectively identifies issues related to variable definitions and usages, such
as unused variables or multiple definitions before use. While it provides valuable insights into
variable handling, it can be time-consuming and requires a good understanding of
programming. Overall, it helps improve code quality by addressing potential data flow issues
early in the development process.
Path Testing
Path Testing is a method that is used to design the test cases. In the path testing method, the
control flow graph of a program is designed to find a set of linearly independent paths of
execution. In this method, Cyclomatic Complexity is used to determine the number of linearly
independent paths and then test cases are generated for each path.
It gives complete branch coverage but achieves that without covering all possible paths of the
control flow graph. McCabe’s Cyclomatic Complexity is used in path testing. It is a structural
testing method that uses the source code of a program to find every possible executable path.
Path Testing Process
Path Testing
Where,
E = Number of edges in the control flow graph
N = Number of vertices in the control flow graph
P = Program factor
Make Set:
Make a set of all the paths according to the control flow graph and calculate cyclomatic
complexity. The cardinality of the set is equal to the calculated cyclomatic complexity.
Create Test Cases:
Create a test case for each path of the set obtained in the above step.
Path Testing Techniques
Control Flow Graph:
The program is converted into a control flow graph by representing the code into nodes and
edges.
Decision to Decision path:
The control flow graph can be broken into various Decision to Decision paths and then
collapsed into individual nodes.
Independent paths:
An Independent path is a path through a Decision to Decision path graph that cannot be
reproduced from other paths by other methods.
Advantages of Path Testing
1. The path testing method reduces the redundant tests.
2. Path testing focuses on the logic of the programs.
3. Path testing is used in test case design.
Disadvantages of Path Testing
1. A tester needs to have a good understanding of programming knowledge or code knowledge
to execute the tests.
2. The test case increases when the code complexity is increased.
3. It will be difficult to create a test path if the application has a high complexity of code.
4. Some test paths may skip some of the conditions in the code. It may not cover some
conditions or scenarios if there is an error in the specific paths.