Professional Documents
Culture Documents
Unit Ii
Unit Ii
Unit Ii
Input Domain
Software
module / random values: 55,
24, system &3
Select test
Black Box input data
Testing / randomly
Random
Testing
Given this approach, some of the issues that remain open are the
following:
Are the three values adequate to show that the module meets its
specification when the tests are run? Should additional or fewer values be
used to make the most effective use of resources?
Are there any input values, other than those selected, more likely to
reveal defects? For example, should positive integers at the beginning or
end of the domain be specifically selected as inputs?
Should any values outside the valid domain be used as test inputs? For
example, should test data include floating point values, negative values,
or integer values greater than 100?
Use of random test inputs may save some time and effort
But, selecting test inputs randomly has very little chance of producing an
effective set of test data
EQUIVALENCE CLASS PARTITIONING
results in a
partitioning of
Invalid inputs Valid inputs
the input
domain of the
software-
under-test.
System
can also be
used to
partition the
output
domain,
Outputs
but this is not
a common
A test value in a particular class is equivalent to a test value of any other
member of that class.
If one test case in a particular equivalence class reveals a defect, all the
other test cases based on that class would be expected to reveal the same
defect.
If a test case in a given equivalence class did not detect a particular type
of defect, then no other test case based on that class would detect the
defect.
Based on this discussion, the partitioning of the input domain for the
software-under-test using this technique has the following advantages:
It eliminates the need for exhaustive testing, which is not feasible.
It guides a tester in selecting a subset of test inputs with a high probability of
detecting a defect.
It allows a tester to cover a larger domain of inputs/outputs with a smaller
subset selected from an equivalence class.
How does the tester identify equivalence classes for the input domain?
Use a set of interesting input conditions.
Input data and output results often fall into different classes
where all members of a class are related
Each of these classes is an equivalence partition where the program
behaves in an equivalent way for each class member
The entire set (union of all classes serves)
Completeness and non-redundancy
Test cases should be chosen from each partition (or class)
Several important points related to equivalence class partitioning should
be made:
- The tester must consider both valid and invalid equivalence classes.
Invalid classes represent erroneous or unexpected inputs.
- Equivalence classes may also be selected for output conditions.
- The derivation of input or outputs equivalence classes is a heuristic
process. The conditions that are described in the following paragraphs
only give the tester guidelines for identifying the partitions. There are no
hard and fast rules.
In some cases it is difficult for the tester to identify equivalence classes.
The
conditions/boundaries that help to define classes may be absent, or obscure,
or there
may seem to be a very large or very small number of equivalence classes for
the
problem domain.
These difficulties may arise from an ambiguous, contradictory, incorrect,
or
incomplete specification and/or requirements description. It is the duty of
the tester
to seek out the analysts and meet with them to clarify these documents.
• If the input specification or any other information leads to the belief that
an element in an equivalence class is not handled in an identical way by
the software-under-test , then the class should be further partitioned into
smaller equivalence classes.
EQUIVALENCE CLASS PARTITIONING –
SQUARE ROOT SPECIFICATION EXAMPLE
Function square_root
message (x:real)
when x >0.0
reply (y:real)
where y >0.0 & approximately (y*y,x)
otherwise reply exception imaginary_square_root
end function
Tester conditions for the specification are relevant to the input and
output variables, x and y.
Input conditions – x (real number, equal to/greater than 0.0)
Output conditions – y (real number, equal to / greater than 0.0 whose
square is approximately equal to x)
If x not equal to /greater than 0.0, then an exception is raised.
From this information, the tester can generate both valid and invalid
equivalence class and boundaries.
• For example, input equivalence classes for this module are the following:
EC1. The input variable x is real, valid.
EC2. The input variable x is not real, invalid.
EC3. The value of x is greater than 0.0, valid.
EC4. The value of x is less than 0.0, invalid.
• After the equivalence classes have been identified in this way, the next
step in test case design is the development of the actual test cases. A good
approach includes the following steps.
1. Each equivalence class should be assigned a unique identifier. A
simple integer is sufficient.
2. Develop test cases for all valid equivalence classes until all have
been covered by (included in) a test case. A given test case may
cover more than one equivalence class.
3. Develop test cases for all invalid equivalence classes until all
have been covered individually. This is to insure that one invalid
case does not mask the effect of another or prevent the execution
of another.
BOUNDARY VALUE ANALYSIS
• complements equivalence partitioning
• If input condition specifies a range bounded by a certain values, say, a
and b, then test cases should include
• The values for a and b
• The values just above and just below a and b
An experienced tester knows that the module could have defects related
to handling widget identifiers that are of length equal to, and directly
adjacent to, the lower boundary of 3 and the upper boundary of 15.
The next step in the test case design process is to select a set of actual
input values that covers all the equivalence classes and the boundaries.
Table 4.2 only describes the tests for the module in terms of inputs
derived from equivalence classes and boundaries.
Note that by inspecting the completed table the tester can determine
whether all the equivalence classes and boundaries have been covered by
actual input test cases.
Example on Boundary Value Analysis Test Case Design Technique:
Assume, we have to test a field which accepts Age 18 – 56
Minimum boundary value is 18
Maximum boundary value is 56
Valid Inputs: 18,19,55,56
Invalid Inputs: 17 and 57
Test case 1: Enter the value 17 (18-1) = Invalid
Test case 2: Enter the value 18 = Valid
Test case 3: Enter the value 19 (18+1) = Valid
Test case 4: Enter the value 55 (56-1) = Valid
Test case 5: Enter the value 56 = Valid
Test case 6: Enter the value 57 (56+1) =Invalid
OTHER BLACK BOX TEST DESIGN
APPROACHES
Cause-and-effect graphing,
State transition testing, &
Error guessing
CAUSE-AND-EFFECT GRAPHING
Major weakness with ECP – does not allow testers to combine conditions
Cause-and-effect graphing – a technique that can be used to combine
conditions and derive an effective set of test cases that may disclose
inconsistencies in a specification.
The specification must be transformed into a graph that resembles a
digital logic circuit.
Tester should have knowledge of Boolean Logic.
The graph must be converted to a decision table that the tester uses to
develop test cases.
Disadvantage – Developing the graph for a complex module with many
combinations of inputs is difficult and time consuming.
The steps in developing test cases with a cause-and-effect graph are as
follows:
The tester must decompose the specification of a complex software component
into lower-level units.
For each specification unit, the tester needs to identify causes and their
effects.
Cause – A cause is a distinct input condition or an equivalence class of
input conditions
Effect – An effect is an output condition or a system transformation.
From the cause-and-effect information, a Boolean cause-and-effect graph is
created. Nodes in the graph are causes and effects. Causes are placed on the
left side of the graph and effects on the right. Logical relationships are
expressed using standard logical operators such as AND, OR, and NOT, and
are associated with arcs.
The graph is then converted to a decision table.
The columns in the decision table are transformed into test cases.
Example:
Suppose we have a specification for a module that allows a user to perform a
search for a character in an existing string. The specification states that the
user must input the length of the string and the character to search for. If the
string length is out-of-range an error message will appear. If the character
appears in the string, its position will be reported. If the character is not in
the string the message “not found” will be output.
The input conditions, or causes are as follows:
C1: Positive integer from 1 to 80
C2: Character to search for is in string
Unreachable states are those that no input sequence will reach, and
may indicate missing transitions.
Dead states are those that once entered cannot be exited.
After the STG has been reviewed formally the tester should plan
appropriate test cases.
A simple approach might be to develop tests that insure that all states
are entered.
For the simple state machine in Figure 4.6 and Table 4.4 the transitions
to be tested are:
Input A in S1
Input A in S2
Input B in S1
Input B in S2
Input C in S1
Input C in S2
The transition sequence requires the tester to describe the exact inputs
for each test as the next step. For example the inputs in the above
transitions might be a command, a menu item, a signal from a device or a
button that is pushed.
Command – “read”
Signal – “hot”
Button – “off”
The exact sequence of inputs must also be described, as well as the
expected sequence of state changes, and actions.
Providing these details makes state-based tests easier to execute,
interpret, and maintain.
In addition, it is best to design each test specification so that the test
begins in the start state, covers intermediate states, and returns to the
start state.
Finally, while the tests are being executed it is very useful for the tester
to have software probes that report the current state (defining a state
variable may be necessary) and the incoming event.
All of these probes allow the tester to monitor the tests and detect
incorrect transitions and any discrepancies in intermediate results.
ERRORGUESSING
Set 1 covers pair 1 for n, pair 2 for sum, and pair 1 for
i. Set 2 covers pair 1 for n, pair 1 for number, pairs
1,3,4 for sum, and pairs 1,2,3,4 for i.
Note even for this small piece of code there are four
tables and four def-use pairs for two of the variables.
As with most white box testing methods, the data flow
approach is most effective at the unit level of testing.
When code becomes more complex and there are more
variables to consider it becomes more time consuming
for the tester to analyze data flow roles, identify
paths, and design the tests.
LOOP TESTING
Most of the white box testing approaches we have discussed so far are associated with
application of an adequacy criterion. Testers are often faced with the decision of which
criterion to apply to a given item under test given the nature of the item and the constraints
of the test environment (time, costs, resources) One source of information the tester
can use to select an appropriate criterion is the test adequacy criterion hierarchy as shown in
Figure 5.5 which describes a subsumes relationship among the criteria. Satisfying an
adequacy criterion at the higher levels of the hierarchy implies a greater thoroughness in
testing [1,14-16]. The criteria at the top of the hierarchy are said to subsume those at the
lower levels. For example, achieving all definition-use (def-use) path adequacy
means the tester has also achieved both branch and statement adequacy. Note from the
hierarchy that statement adequacy is the weakest of the test adequacy criteria.
Unfortunately, in many organizations achieving a high level of statement coverage is not even
included as a minimal testing goal.
• As a conscientious tester you might at first reason that your testing goal
should be to develop tests that can satisfy the most stringent criterion.
However, you should consider that each adequacy criterion has both
strengths and weaknesses. Each, is effective in revealing certain types of
defects. Application of the so-called Stronger criteria usually requires more
tester time and resources. This translates into higher testing costs. Testing
conditions, and the nature of the software should guide your choice of a
criterion.
•
Support for evaluating test adequacy criteria comes from a theoretical
treatment developed by
Weyuker . She presents a set of axioms that allow testers to formalize
properties which should be
satisfied by any good program-based test data adequacy criterion. Testers
can use the axioms to
recognize both strong and weak adequacy criteria; a tester may decide
to use a weak criterion,
but should be aware of its weakness with respect to the properties
described by the axioms;
• focus attention on the properties that an effective test data adequacy
criterion should exhibit;
• select an appropriate criterion for the
item under test;
• stimulate thought for the development of new criteria; the axioms
are the framework with
which to evaluate these
new criteria.
The axioms are based on the following set of assumptions :