What are software testing techniques?
Software testing is a critical element of the software development life cycle and represents the ultimate review of the specification,
design, and code generation.
The increasing visibility of software as a system element and the attendant "costs" associated with a software failure is
motivating forces for well-planned and thorough testing.
Once the source code has been generated, software must be tested to uncover (and rectify)
as many errors and defects as possible before delivering it to your customer. Your goal is to design a series of
test cases that have a high likelihood of finding errors- but how?
That's where software testing techniques come into the picture.
These techniques provide systematic guidance for designing tests that -
1. Excercise the internal logic of software components and
2. Excercise the input and output domains of the program to uncover errors in program function,
behavior, and performance.
Importance of software testing techniques:
Reviews and other SQA activities are not sufficient to uncover errors.
every time the program is executed, the customer tests it. therefore we have to execute the program
before it gets to the customer with the specific intent of finding and removing all the errors.
In order to find the highest possible number of errors, the tests must be conducted systematically and
test cases must be designed using disciplined techniques.
Software is tested from two different perspectives:
1. Internal program logic is executed using "white box" test case design techniques.
2. Software requirements are exercised using "black box" test case design techniques.
In both cases, the intent is to find maximum defects and errors with the minimum amount of
effort and time.
White-box testing:
white-box testing also called glass-box testing is a test case design method that uses the control structure
of the procedural design to derive test cases.
Using white box testing methods, the software engineer can derive test cases that-
1. Guarantee that all the independent paths within a module have been exercised at least once
2. Exercise all the logical decisions on their true and false sides
3. Execute all the loops at their boundaries and within their operational bounds
4. Exercise internal data structures to ensure their validity.
White box testing techniques:
1. Basis path testing
2. Control structure testing
Basis path testing:
Basis path testing is a white-box testing technique. 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. Before the basis path method can be introduced, a simple notation for the representation of control flow, called flow graph (or program graph) must be introduced. The flow graph depicts logical control flow using the notation illustrated below:Cyclomatic complexity:
cyclomatic complexity is a software metric that provides a quantitative measure of the
logical complexity of a program. When used in the context of the basis path testing method, the value computed for
cyclomatic complexity defines the number of independent paths
in the basis set of a program and provides us with an upper bound
for the number of tests that must be conducted to ensure that all the statements have been executed at least once.
cyclomatic complexity is defined as -
V(G)=E-N+2
where E is the number of flow graph edges, and N is the number of flow graph nodes.
cyclomatic complexity is also defined as -
V(G)=P+1
where P is the number of predicate nodes contained in the flow graph G.
Edges- An arrow on the flow graph represents a flow of control. An edge must terminate at a node.
Nodes- A node in a flow graph represents a procedural statement.
Regions- Areas bounded by edges and nodes are called regions.
Independent paths- An independent path is any path through the program that introduces at least one
new set of processing statements or a new condition.
Control structure testing:
The control structure testing is further classified as below:
1. Condition testing:
2. Loop testing
Condition testing is a test case design method that exercises the logical conditions contained in a program module.
A simple condition is a boolean variable or a relational expression, possibly preceded with one NOT(-) operator.
Loop testing is one of the white-box testing techniques that focuses on the validity of a loop construct.
Four types of loops are validated in loop testing:
simple loops, nested loops, concatenated loops, and unstructured loops.
Some common tests that are to be performed on simple loops are (considering 'n' as the number of iterations)
1. skipping the loop entirely
2. one pass through the loop (covering all the n iterations)
3. m passes through the loop (where m is less than n)
4. n-1, n, and n+1 iterations through the loop.
In the case of nested loops, the following common tests are to be performed:
start with the innermost loop and conduct a simple loop test on the innermost loop and hold the outer loops at their minimum iterations. Also, conduct tests for out-of-range and excluded values on the loop parameters.
Black box testing
Black box testing is also known as functional testing or behavioral testing mainly focuses on
functional aspects of the system and information domain.
In black-box testing, a set of input conditions are derived that fully exercise all the functional requirements of
a system or software program.
It is altogether a different approach to uncover a different class of defects than the white-box methods.
Usually, the black-box testing approach is applied at a later stage, unlike the white-box testing that is introduced
at an early stage of the software development cycle.
Black-box test cases are designed to check:
1. The functional validity of the system,
2. Integration of different components of the system and checking the errors in interfacing.
2. System behavior with different sets of input data
3. System performance with a varied amount of data volume
4. The effect on the system if different combinations of data inputted in the system
Some common Black-box testing techniques are :
1. Equivalence partitioning
2. Boundary value analysis
Equivalence partitioning is a black-box testing technique that divides the input domain of a program into
classes of data from which test cases can be derived.
Equivalence partitioning is a technique that reduces the number of test cases yet uncovers all the classes of errors
that may arise from inputting different sets of data. Test case design for equivalence partitioning is based
on an evaluation of equivalence classes for an input condition. An equivalence class denotes a set of
valid and invalid states for input conditions. An input condition is anything like - a specific
numeric value, a range of values, a set of related values, or a boolean condition.
Boundary value analysis:
It is a testing technique that tends to evaluate and exercise bounding values.
BVA complements equivalence partitioning and focuses on selecting the test cases at the edges of
the class. For e.g. if an input condition specifies a range of numeric values from 100 to 1000,
then the test cases covering BVA will include inputting 99, 100, 101, 999, 1000, 1001.
if an input condition specifies a number of random values like - 45, 66, 21, 25, 30, 89, 44, 102
then the BVA test cases will cover minimum, maximum values, along with values just
above and below minimum and maximum are tested.
here, 21, 102, 25, 89 will be the BVA coverage for the condition given above.