0% found this document useful (0 votes)
35 views14 pages

Unit 3

software testing and automation unit 3

Uploaded by

geetha.pv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views14 pages

Unit 3

software testing and automation unit 3

Uploaded by

geetha.pv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Software Testing – Boundary Value Analysis

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)

Invalid Valid Invalid


(min-1) (min, min + 1, nominal, max – 1, max) (max + 1)
Boundary Value Analysis(Age accepts 18 to 56)

17 18, 19, 37, 55, 56 57

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

1 6 15 1900 14 June 1900

2 6 15 1901 14 June 1901

3 6 15 1960 14 June 1960

4 6 15 1999 14 June 1999

5 6 15 2000 14 June 2000

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

6 6 1 1960 31 May 1960

7 6 2 1960 1 June 1960

8 6 30 1960 29 June 1960

9 6 31 1960 Invalid day

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

10 1 15 1960 14 Jan 1960

11 2 15 1960 14 Feb 1960

12 11 15 1960 14 Nov 1960

13 12 15 1960 14 Dec 1960

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

1 Enter value 0 to 5 character Not accepted


Test Scenario Test Description Expected Outcome

2 Enter 6 to 10 character Accepted

3 Enter 11 to 14 character Not Accepted

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.

Equivalence Class Testing- Next date problem

Equivalence class testing (Equivalence class Partitioning)


is a black-box testing technique used in software testing as a major step in the
Software development life cycle (SDLC)
. This testing technique is better than many of the testing techniques like boundary value
analysis, worst case testing, robust case testing and many more in terms of time consumption
and terms of precision of the test cases. Since testing is done to identify possible risks,
equivalence class testing performs better than the other techniques as the test cases generated
using it are logically identified with partitions in between to create different input and output
classes. This can be shown from the next-date problem which is stated below: Given a day in
the format of day-month-year, you need to find the next date for the given date. Perform
boundary value analysis and equivalence-class testing for this.
Conditions :
D: 1<Day<31
M: 1<Month<12
Y: 1800 <Year <2048
Boundary Value Analysis:
No. of test Cases (n = no. of variables) = 4n+1 = 4*3 +1 =13
Test Cases:
Test Case ID Day MonthYear Expected Output

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

5 31 6 2000 Invalid Date

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

Equivalence Class Testing:


Input classes:
Day:
D1: day between 1 to 28
D2: 29
D3: 30
D4: 31
Month:
M1: Month has 30 days
M2: Month has 31 days
M3: Month is February
Year:
Y1: Year is a leap year
Y2: Year is a normal year
Output Classes:
Increment Day
Reset Day and Increment Month
Increment Year
Invalid Date
Strong Normal Equivalence Class Test Cases:

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

E10 29 1 2003 30-1-2003

E11 29 2 2004 1-3-2004

E12 29 2 2003 Invalid Date

E13 30 4 2004 1-5-2004

E14 30 4 2003 1-5-2003

E15 30 1 2004 31-1-2004

E16 30 1 2003 31-1-2003

E17 30 2 2004 Invalid Date

E18 30 2 2003 Invalid Date

E19 31 4 2004 Invalid Date

E20 31 4 2003 Invalid Date


Test Case ID Day MonthYear Expected Output

E21 31 1 2004 1-2-2004

E22 31 1 2003 1-5-2003

E23 31 2 2004 Invalid Date

E24 31 2 2003 Invalid Date

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.

Data Flow Testing


Data Flow Testing is a type of structural testing . It is a method that is used to find the test
paths of a program according to the locations of definitions and uses of variables in the
program. It has nothing to do with data flow diagrams. Furthermore, it is concerned with:
 Statements where variables receive values,
 Statements where these values are used or referenced.
By analyzing control flow graphs, this technique aims to identify issues such as unused
variables or incorrect definitions, ensuring proper handling of data within the code.

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-

DEF(S) = {X | statement S contains the definition of X}


USE(S) = {X | statement S contains the use of X}

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:

Define/use of variables of above example:


Variable Defined at node Used at node

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

 Control Flow Graph:


Draw the corresponding control flow graph of the program in which all the executable paths
are to be discovered.
 Cyclomatic Complexity:
After the generation of the control flow graph, calculate the cyclomatic complexity of the
program using the following formula.
McCabe's Cyclomatic Complexity = E - N + 2P

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.

You might also like