You are on page 1of 50

Testing Methods

Black Box Testing


• Behavioral Testing, is a software testing method in which the internal
structure/design/implementation of the item being tested is not
known to the tester.

This method is named so


because the software program,
in the eyes of the tester, is like
a black box;

A tester, without knowledge of the internal


structures of a website, tests the web pages
by using a browser; providing inputs (clicks,
keystrokes) and verifying the outputs against
the expected outcome.
Black box testing
• This method attempts to find errors in the following categories:
• Incorrect or missing functions
• Interface errors
• Errors in data structures or external database access
• Behavior or performance errors
• Initialization and termination errors
• Levels Applicable To:
• Integration Testing
• System Testing
• Acceptance Testing
Black Box Approaches
• Black Box Approaches:
• Equivalence Partitioning
• Boundary Value Analysis
• Cause Effect Analysis
• Cause Effect Graphing
• Error Guessing
Equivalence Partitioning
• Equivalence partitioning is partitioning the input domain of a system
into finite number of equivalent classes
• Check whether the program extends similar behavior or treatment to
a certain group of inputs
• If such a group of values can be found in the input domain treat them
together as one equivalent class and test one representative from
this.
Example-EP
• Consider a program which takes “Salary” as input with values
12000...37000 in the valid range.
• The program calculates tax as follows:
• Salary up to Rs. 15000 – No Tax
• Salary between 15001 and 25000 – Tax is 18 % of Salary
• Salary above 25000 – Tax is 20% of Salary
• Three valid equivalent classes are:
• c1 : values in the range 12000...15000
• c2: values in the range 15001...25000
• c3: values > 25000
Example-EP
• However, it is not sufficient that we test only valid test cases.
• We need to test the program with invalid data also as the users of the
program may give invalid inputs, intentionally or unintentionally.
• It is easy to identify an invalid class
• c4: values < 12000
Equivalent classes identified

15001

25001
EP
• To design test cases using equivalence partitioning, for a range of
valid input values identify
• one valid value within the range
• one invalid value below the range and
• one invalid value above the range
EP
• Similarly, To design test cases for a specific set of values
• one valid case for each value belonging to the set
• one invalid value
• Test Cases for Types of Account (Savings, Current) will be
• Savings, Current (valid cases)
• Overdraft (invalid case)
• It may be noted that we need fewer test cases if some test cases can
cover more than one equivalent class.
2. Boundary Value Analysis
• Equivalence partitioning states that testing one value from a class
is equivalent to testing any other value from that class,
• Look at the boundaries of equivalent classes more closely.
• Boundaries are more error prone.
• To design test cases using boundary value analysis, for a range of
values,
• Two valid cases at both the ends
• Two invalid cases just beyond the range limits
The test cases using boundary value analysis
are

1
3. Cause Effect Analysis
• drawback of the EP and BVAthey do not explore the combination
of input conditions.
• Cause effect analysis is an approach for studying the specifications
carefully and identifying the combinations of input conditions
(causes) and their effect in the form of a table and designing test
cases
• It is suitable for applications in which combinations of input
conditions are few and readily visible
4. Cause Effect Graphing
• This is a rigorous approach, recommended for complex systems only.
• In such systems the number of inputs and number of equivalent
classes for each input could be many and hence the number of input
combinations usually is astronomical.
• Hence we need a systematic approach to select a subset of these
input conditions.
Guidelines for Graphing
• Divide specifications into workable pieces as it may be practically difficult to work on large
specifications.
• Identify the causes and their effects.
• A cause is an input condition or an equivalence class of input conditions.
• An effect is an output condition or a system transformation.
• Link causes and effects in a Boolean graph which is the cause-effect graph.
• Make decision tables based on the graph. This is done by having one row each for a node in the
graph.
• The number of columns will depend on the number of different combinations of input conditions
which can be made
• Convert the columns in the decision table into test cases.
Example
Example to check whether the given input
forms a triangle
• Firstly: Recognize and describe the input conditions (causes) and
actions (effect).

The causes allocated by letter “C” are as follows,


The effects designated by letter “e” are as follows,
C1: Side “x” is less than sum of “y” and “z” e1: Not a triangle
C2: Side “y” is less than sum of “x” and “z” e2: Scalene triangle
C3: Side “z” is less then sum of “x” and “y” e3: Isosceles triangle.
C4: Side “x” is equal to side “y” e4: Equilateral triangle
C5: Side “x” is equal to side “z” e5: Impossible
C6: Side “y” is equal to side “z”
Example to check whether the given input
forms a triangle
• Secondly: Build up a cause-effect graph
Example to check whether the given input forms a
triangle
• Third: Convert cause- Y<X+Z?
effect graph into a
decision table Z<X+Y?
• Fourth: 11 test
cases according
to the 11 rules.
Error Guessing
• Error guessing is a supplementary technique where test case design is
based on the tester's intuition and experience.
• There is no formal procedure. However, a checklist of common errors
could be helpful here.
White Box Testing
WHITE BOX TESTING
• is a software testing method in which the internal structure/design/
implementation of the item being tested is known to the tester.
• The tester chooses inputs to exercise paths through the code and
determines the appropriate outputs.
• Programming know-how and the implementation knowledge is
essential.
• White box testing is testing beyond the user interface and into the
nitty-gritty of a system
White Box testing
White Box Approach
• Basis Path Testing
Basis Path Testing
• Basis Path Testing is white box testing method where we design test
cases to cover every statement, every branch and every predicate
(condition) in the code which has been written.
• Thus the method attempts statement coverage, decision coverage
and condition coverage.
Basic path testing
• First proposed by Tom McCabe.
• Can be used to derive a logical complexity measure for a procedure
design.
• Used as a guide for defining a basis set of execution path.
• Guarantee to execute every statement in the program at least one
time.
Basis Path Testing-Control flow Graph
• structured-constructs in a flow graph
Control Flow Graph
Ex: CFG

Source: geeksforgeeks.org
Basis Path Testing
binarySearch() Example
CFG of Binary search
Cyclomatic Complexity
Properties of Cyclomatic complexity:
• Following are the properties of Cyclomatic complexity:
• V (G) is the maximum number of independent paths in the graph
• V (G) >=1
• G will have one path if V (G) = 1
• Minimize complexity to 10
CC-Independent path
Cyclomatic Complexity-Ways
Different methods to calculate V(G)
Steps to be followed in cC
• The following steps should be followed for computing Cyclomatic
complexity and test cases design.
• Step 1 - Construction of graph with nodes and edges from the code
• Step 2 - Identification of independent paths
• Step 3 - Cyclomatic Complexity Calculation
• Step 4 - Design of Test Cases
• Once the basic set is formed, TEST CASES should be written to
execute all the paths.
Cyclomatic Complexity of Function
binarySearch()
CC Number
Complexity Number Meaning
Structured and well written code
1-10 High Testability
Cost and Effort is less
Complex Code
10-20 Medium Testability
Cost and effort is Medium
Very complex Code
20-40 Low Testability
Cost and Effort are high
Not at all testable
>40
Very high Cost and Effort
Deriving Basis Test Cases
Deriving Basis Test Cases Contd..
Deriving Basis Test Cases
Other Example
Find the complexity?

You might also like