You are on page 1of 53

Test Strategies for

Conventional
Software
Test Strategies for Conventional Software
The conventional applications, the software is tested
from two different perspectives:
• Internal program logic is exercised using “white box” test-case
design techniques.

• Software requirements are exercised using “black box” test-case


design techniques.

• Use cases assist in the design of tests to uncover errors at the software validation level.
Software Testing Fundamentals
• Testability- Software testability is simply how easily [a computer program]
can be tested.

Operability
Understandability
Observability

Stability. Testability

Controllability
Simplicity Decomposability
Software Testing Fundamentals Cont’d
Testability:
Operability - The better it works, the more efficiently it can be tested.

Observability - What you see is what you test.


Controllability - The better we can control the software, the more the testing can be automated
and optimized.

Decomposability - By controlling the scope of testing, we can more quickly isolate problems and
perform smarter retesting.

Simplicity - The less there is to test, the more quickly we can test it.

Stability - The fewer the changes, the fewer disruptions to testing.

Understandability - The more information we have, the smarter we will


test.
Software Testing Fundamentals

Test Characteristics
• A good test has a high probability of finding an error.
• A good test is not redundant.
• A good test should be “best of breed”
• A good test should be neither too simple nor too complex.
White-box Testing
• White-box testing sometimes called glass-box or structural testing

• White box testing is a testing technique, that examines the program structure
and
derives test data from the program logic/code.

White Box Testing Techniques


• Path Coverage - This technique corresponds to testing all possible paths
which means that each statement and branch is covered.

• Statement Coverage - This technique is aimed at exercising all programming


statements with minimal tests.

• Branch Coverage (Control Structure )- This technique is running a series of


tests to ensure that all branches are tested at least once.
1.Basis Path Testing
• The basis path method enables the test-case designer to derive a logical
complexity measure of a procedural design and use this measure as a guide
for defining a basis set of execution paths.

• Test cases derived to exercise the basis set are guaranteed to execute
every statement in the program at least one time during testing.

Basis Path Testing Steps: • Construct the Control Flow Graph


• Compute the Cyclomatic Complexity of the Graph
• Identify the Independent Paths
• Design Test cases from Independent Paths
1.Flow Graph Notation

• Control flow depicts a program as a graph that consists of Nodes and Edges.

• In the graph, Nodes represent processing tasks while


edges represent control flow between the nodes.

Flow grah notation for a program


Flow Graph Notation Cont’d
Control Flow Chart

First, we compute the cyclomatic


complexity:
Number of simple decisions + 1

or

Number of enclosed areas + 1

In this case, V(G) = 4


Cyclomatic Complexity in Software Testing

• To understand Cyclomatic Complexity, lets first understand

What is Software Metric?

A software metric is defined as a quantitative measure of an attribute a


software system possesses with respect to Cost, Quality, Size, and Schedule.

Example

Measure - No. of Errors


Metrics - No. of Errors found per person
Cyclomatic Complexity in Software Testing
Cont’d
• Cyclomatic Complexity in Software Testing is a testing metric used for
measuring the complexity of a software program.

• Cyclomatic complexity can be calculated by using control flow graphs or


with respect to functions, modules, methods or classes within a software
program.

This metric was developed by Thomas J.


McCabe in 1976
How to Calculate Cyclomatic Complexity
Mathematical representation:
• Mathematically, it is a set of independent paths through the graph diagram.

•The Code complexity of the program can be defined using the formula:

Complexity is computed in one of three ways


1. The number of regions of the flow graph corresponds to the cyclomatic
complexity.
2.V(G) = E - N + 2
3. V (G) = P + 1
Where,
Where,
E – Number of edges
P = Number of predicate nodes (node that contains condition)
N – Number of
How to Calculate Cyclomatic Complexity
Control Flow Chart
Example
Cyclomatic Complexity
A = 10

IF B > C THEN
The graph shows seven
A=B
shapes(nodes), seven lines(edges),
ELSE hence cyclomatic complexity is 7-
A=C 7+2 = 2.

ENDIF

Print

Print B
How to Calculate Cyclomatic Complexity
Example Flow graph
i = 0;
n=4; //N-Number of nodes Cyclomatic Complexity
present in the graph

while (i<n-1) do V(G) = 9 – 7 + 2 = 4


j = i + 1;
V(G) = 3 + 1 = 4 (Condition nodes are
while (j<n) do 1,2 and 3 nodes).

if A[i]<A[j] then Basis Set – A set of possible execution paths


swap(A[i], of a program
A[j]);
Path1- 1, 7
end do; Path2- 1, 2, 6, 1, 7
j=j+1;
Path3- 1, 2, 3, 4, 5, 2, 6, 1, 7
end do; Path4- 1, 2, 3, 5, 2, 6, 1, 7
How to Calculate Cyclomatic Complexity

Control Flow Chart Control Flow graph

Cyclomatic Complexity

1. The flow graph has four regions.

2. V(G) 11 edges -9 nodes +2 =


4.

3. V(G) 3 predicate nodes + 1 =


4.
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

How this metric is useful for software testing


• It checks each linearly independent path through the program, which
means the number of test cases, will be equivalent to the cyclomatic complexity of
the program.
How Cyclomatic complexity metric
is useful for software testing
This metric is useful because of the properties of Cyclomatic complexity (M) –

1.M can be the number of test cases to achieve branch coverage (Upper Bound)

2.M can be the number of paths through the graphs. (Lower Bound)

Example

If (Condition 1) The Cyclomatic Complexity for this program will be 8-7+2=3.


Statement 1
Else • As complexity has been calculated as 3, three test cases
Statemen
t2
are necessary to complete path coverage.
If
(Condition 2)
Statement 3
Else
The complexity number and corresponding meaning of v (G)
Complexity Number Meaning

1-10 Structured and well written code

High Testability

Cost and Effort is less

10-20 Complex Code

Medium Testability
Cost and effort is
Medium
20-40 Very complex Code

Low Testability
Cost and Effort
are high
>40 Not at all testable
Very high Cost and Effort
Uses of Cyclomatic Complexity

Cyclomatic Complexity can prove to be very helpful in


• Helps developers and testers to determine independent path executions

• Developers can assure that all the paths have been tested atleast once

• Helps us to focus more on the uncovered paths

• Improve code coverage in Software Engineering

• Evaluate the risk associated with the application or program

• Using these metrics early in the cycle reduces more risk of the program
Independent Program Paths
• An independent path is any path through the program that introduces at
least one new set of processing statements or a new condition.

1-2-3-4-5-10-1-2-3-6-8-9-10-1-11

Not independent path

Finally, after obtaining the independent paths, test cases can be designed where
Design Test Cases
each test case represents one or more independent paths.
Graph Matrices
• The procedure for deriving the flow graph and even determining a set of
basis paths is amenable to mechanization.
• A data structure, called a graph matrix, can be quite useful for developing
a software tool that assists in basis path testing.

• The graph matrix is nothing more


than a tabular representation of a
flow graph.

• The graph matrix can become a


powerful tool for evaluating program
control structure during testing
2.Control Structure Testing
• Control structure testing is a group of white-box testing methods.

• Control structure testing is used to increase the coverage area by


testing various control structures present in the program.

Control Structure Testing

Condition Testing Data Flow Testing Loop Testing


Condition Testing
• Condition testing is a test case design method, which ensures that the
logical condition and decision statements are free from errors.

• The errors present in logical conditions can be incorrect Boolean


operators, missing parenthesis in a Booleans expression, errors in
relational operators, arithmetic expressions, and so on

Methods for Condition Testing


• Branch testing
Data Flow Testing
• The data flow test method chooses the test path of a program based on
the locations of the definitions and uses all the variables in the
program.
• 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:

•If the variables are used without initialization.

•If the initialized variables are not used at least once.


Loop Testing
• The loop testing completely focuses on the validity of the loop
constructs.

Loop Testing

Concatenated Unstructured
Simple loop Nested loop
loop loop
Why do Loop Testing
• Testing can fix the loop repetition issues.

• Loops testing can reveal performance/capacity bottlenecks.

• By testing loops, the uninitialized variables in the loop


can be determined.

• It helps to identify loop initialization problems.


Types of loop Tested
Loop Testing: Simple Loops
Minimum conditions—Simple Loops

• Skip the entire loop

• Make 1 pass through the loop

• Make 2 passes through the loop

• Make a passes through the loop where a<b, n is the maximum number
of passes through the loop

• Make b, b-1; b+1 passes through the loop where “b” is the maximum
number of allowable passes through the loop.
Loop Testing: Nested Loops

• Adjust all the other loops to their minimum value and start
with the deepest loop.

• Start a simple loop test on the innermost loop and keep the
outside loops at their minimum iteration parameter value.

• Conduct the test for the following loop and make your way
outwards.

• Keep testing till reached the outermost loop.


Concatenated and Unstructured
Loop
Concatenated Loop
• In the concatenated loops, if two loops are tested as independent of
each other then they both are tested using simple loops or else
test them as nested loops.

Unstructured Loop

• The unstructured loop is the combination of nested loops and


concatenated loops. It is basically a collection of loops that are in no
order.
Black-box Testing
Black-box Testing
• Black Box Testing is also known as behavioral, opaque-box, closed-
box,
specification-based or eye-to-eye testing.

• 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
Black-box Testing

• 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.
Types of Black Box Testing

Functional Testing Non - Functional Testing

• Smoke Testing • Usability Testing


• Sanity Testing • Load Testing
• Integration Testing • Performance Testing
• System Testing • Compatibility Testing
• Regression Testing • Stress Testing
• User Acceptance Testing • Scalability Testing
Black Box Testing Techniques

Equivalence Partitioning

Boundary Value Analysis

Decision Table Testing

Black Box Testing Techniques


State Transition Testing

Error Guessing

Graph-Based Testing Methods

Comparison Testing
Black Box Testing Techniques Cont’d

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.

• This reduced the test cases to only 3 test


cases based on the formed classes thereby
covering all the possibilities.
Black Box Testing Techniques Cont’d
2.Boundary Value Analysis
• Boundary testing is the process of testing between extreme ends or boundaries between
partitions of the input values.

• Boundary refers to values near the limit where the behavior of the system changes.

• In boundary value analysis, both valid and invalid inputs are being tested to verify
the
issues. 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.
Black Box Testing Techniques Cont’d
3. Decision Table Testing

• A Decision Table is a tabular representation of versus


inputs
rules/cases/test conditions. It is a very effective tool used for
both complex software testing.

• A decision table helps to check all possible combinations of conditions for


testing and testers can also identify missed conditions easily.

• The conditions are indicated as True(T) and False(F) values.


Black Box Testing Techniques Cont’d

3. Decision Table Testing Cont’d


Example
• The
condition is

simple if

the
user
provides
the
correct
username and password the user
will be redirected to the
homepage.
Black Box Testing Techniques Cont’d

4. State Transition Testing

• 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.
Black Box Testing Techniques Cont’d

4. State Transition Testing Cont’d

• 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
them less effective.
Black Box Testing Techniques Cont’d
5. Error Guessing
• This is a classic example of Experience-Based Testing.

• The tester can use his/her experience with the application behavior and
functionalities to guess the error-prone areas.

• Many defects can be found using error guessing where most of


the
developers usually make mistakes.•Divide by zero.
Examples •Handling null values in text fields.
•Accepting the Submit button without any value.
•File upload without attachment.

File upload with less than or more than the limit size.
Black Box Testing Techniques Cont’d
6. Graph-Based Testing Methods

• Each and every application is a build-up of some objects.

• All such objects are identified and the graph is prepared.

• From this object graph, each object relationship is identified and test
cases are written accordingly to discover the errors.

• It is a helpful technique to understand the software’s functional


performance, as it visualizes the flow of inputs and outputs in a lively
fashion.
Black Box Testing Techniques Cont’d
6. Graph-Based Testing Methods

The graph could represent


• Control flow through a program

• Data flow between variables

• An activity diagram, showing the workflow when a user interacts with the system

• A state diagram, showing the states of a system and transitions between them
Black Box Testing Techniques Cont’d
Graph-Based Testing Methods -Major Steps

• Step 1: Build a graph model


– What information is to be captured, and how to
represent that
information?
• Step 2: Identify test requirements (TR)
–A test requirement is a structural entity in the graph model
that must be covered during testing
• Step 3: Select test paths to cover those requirements
• Step 4: Derive test data so that the test paths can be executed
Black Box Testing Techniques Cont’d

Graph notation

Sample Example
Comparison Testing
• Comparison testing identifies the strengths and weaknesses of
a software product against other software products that
already exist in the market and are readily used by the target
audience.

• A comparison test will help you understand whether or not your


software project will be a marketable one after its commercial
release.
When Comparison Testing is Performed
• Early stage of the software development process.
• Changes in business requirements or design of software products can be captured in
the early stages.

• Mid-stage of the software development process


• User Interface elements and behaviour of each functionality of software product can
be compared and improved in this stage of the software development process.

• End of the software development process


• Quality, processing speed, and support of hardware and software to run products can
be evaluated alongside the critical business objectives in the last stage.
Orthogonal Array Testing
• The orthogonal Array Testing technique is a statistical approach for
testing pair-wise interactions.

• Most of the defects which I have observed are caused due to


interaction and integration.

• This interaction or integration can be within different objects,


elements, options on a screen of the application, or configuration
settings in a file.

• So, OAT is useful to test a large number of possible input combinations.

• It uses a very less number of Test cases.


Orthogonal Array Testing

Terminologies in Orthogonal Array Testing

LRuns (Levels Factors)

• Runs It is the number of rows that represents the number of test conditions to be
performed.

• Factors It is the number of columns that represent in the number of variables to be tested

• Levels It represents the number of values for a Factor


Orthogonal Array Testing Cont’d
• The orthogonal array testing method is particularly useful in finding region faults—an
error category associated with faulty logic within a software component.

Example 1

A Web page has three distinct sections (Top, Left, Right)


that can be individually shown or hidden from a user

No of Factors = 3 (Top, Left, Right)

No of Levels (Visibility) = 2 (Hidden or Shown)

Array Type = L4(23) The orthogonal array we can test


For traditional testing, we need to write 8 Test cases
Difference Between White Box Testing and
Black Box Testing
White Box Testing
Black Box Testing

• It is a testing method without having knowledge • It is a testing method having knowledge about

about the actual code or internal structure of the actual code and internal structure of the

the application. application.

• This is a higher level testing such as functional • This type of testing is performed at a lower

testing. level of testing such as Unit Testing,

Integration Testing.

• It concentrates on the functionality of • It concentrates on the actual code – program

the system under test. and its syntax's.

• Black box testing requires • White Box testing requires Design

Requirement specification to test. documents with data flow diagrams, flowcharts

etc.
Model-based Testing
• The model-based testing technique uses UML state diagrams

The MBT technique requires five steps

1. Analyze an existing behavioral model for the software or create one.

2. Traverse the behavioral model and specify the inputs that will force the software to
make the transition from state to state.

3. Review the behavioral model and note the expected outputs as the software makes the
transition from state to state.

4. Execute the test cases.

5. Compare actual and expected results and take corrective action as required

You might also like