0% found this document useful (0 votes)
18 views25 pages

Software Testing & Quality - Wk5

Uploaded by

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

Software Testing & Quality - Wk5

Uploaded by

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

Click to edit Master title style

Software Testing & Quality


Te s t - C a s e D e s i g n

1
Click to edit Master title style

Test-Case Design

2 2
Click to edit
Test-Case Design
Master title style

• What subset of all possible test cases has the highest


probability of detecting the most errors?
• Random-input testing is not very effective
• Use the black-box methods first, then the white-box
methods

3 3
Click to edit
Test-Case Design
Master title style

Black-Box Testing White-Box Testing

1. Equivalence partitioning 1. Statement coverage


2. Boundary value analysis 2. Decision coverage
3. Cause-effect graphing 3. Condition coverage
4. Error guessing 4. Decision/condition coverage
5. Multiple-condition coverage

4 4
Click to edit
Boundary Value
Master
Analysis
title style

• Rather than selecting any element in an equivalence


class as being representative, boundary value analysis
requires that one or more elements be selected such
that each edge of the equivalence class is the subject
of a test.
• Rather than just focusing attention on the input
conditions (input space), test cases are also derived by
considering the result space (output equivalence
classes).

5 5
Click to edit
Boundary Value
Master
Analysis
title style

1. If an input condition specifies a range of values,


write test cases for the ends of the range, and
invalid-input test cases for situations just beyond the
ends. For instance, if the valid domain of an input
value is –1.0 to 1.0, write test cases for the
situations –1.0, 1.0, –1.001, and 1.001.
2. If an input condition specifies a number of values,
write test cases for the minimum and maximum
number of values and one beneath and beyond these
values. For instance, if an input file can contain
1–255 records, write test cases for 0, 1, 255, and
256 records.
3. Use guideline 1 for each output condition. For
instance, if a payroll program computes the monthly
FICA deduction, and if the minimum is $0.00 and
the maximum is $1,165.25, write test cases that
cause $0.00 and $1,165.25 to be deducted. Also, 6 6

see whether it is possible to invent test cases that


Click to edit
Boundary Value
Master
Analysis
title style

4. Use guideline 2 for each output condition. If an


information retrieval system displays the most
relevant abstracts based on an input request, but
never more than four abstracts, write test cases such
that the program displays zero, one, and four
abstracts, and write a test case that might cause the
program to erroneously display five abstracts.
5. If the input or output of a program is an ordered
set (a sequential file, for example, or a linear list or
a table), focus attention on the first and last
elements of the set.
6. In addition, use your ingenuity to search for other
boundary conditions.

7 7
Click to edit
Boundary Value
Master
Analysis
title style

MTEST is a program that grades multiple-choice examinations.


The input is a data file named OCR, with multiple records that
are 80 characters long. Per the file specification, the first
record is a title used as a title on each output report. The next
set of records describes the correct answers on the exam. These
records contain a ‘‘2’’ as the last character in column 80. In
the first record of this set, the number of questions is listed in
columns 1–3 (a value of 1–999). Columns 10–59 contain the
correct answers for questions 1–50 (any character is valid as
an answer). Subsequent records contain, in columns 10–59,
the correct answers for questions 51–100, 101–150, and so
on.
The third set of records describes the answers of each student;
each of these records contains a ‘‘3’’ in column 80. For each
student, the first record contains the student’s name or
number in columns 1–9 (any characters); columns 10–59
contain the student’s answers for questions 1–50. If the test 8 8
has more than 50 questions, subsequent records for the
Click to edit
Boundary Value
Master
Analysis
title style

The four output records are:


1. A report, sorted by student identifier,
showing each student’s grade (percentage of
answers correct) and rank.
2. A similar report, but sorted by grade.
3. A report indicating the mean, median, and
standard deviation of the grades.
4. A report, ordered by question number,
showing the percentage of students
answering each question correctly

9 9
Click to edit
Boundary Value
Master
Analysis
title style

1010
Click to edit
Boundary Value
Master
Analysis
title style

1111
Click to edit Master
Cause-Effect Graphing
title style

1. The specification is divided into workable pieces. This


is necessary because cause-effect graphing becomes
unwieldy when used on large specifications.
For instance, when testing an e-commerce system, a
workable piece might be the specification for choosing
and verifying a single item placed in a shopping cart.
When testing a Web page design, you might test a
single menu tree or even a less complex navigation
sequence.

1212
Click to edit Master
Cause-Effect Graphing
title style

2. The causes and effects in the specification are


identified. A cause is a distinct input condition or an
equivalence class of input conditions. An effect is an
output condition or a system transformation (a
lingering effect that an input has on the state of the
program or system). You identify causes and effects
by reading the specification word by word and
underlining words or phrases that describe causes
and effects. Once identified, each cause and effect is
assigned a unique number.
For instance, if a transaction causes a file or database
record to be updated, the alteration is a system
transformation; a confirmation message would be an
output condition.

1313
Click to edit Master
Cause-Effect Graphing
title style

3. The semantic content of the specification is analyzed


and transformed into a Boolean graph linking the
causes and effects. This is the cause-effect graph.
4. The graph is annotated with constraints describing
combinations of causes and/or effects that are
impossible because of syntactic or environmental
constraints.
5. By methodically tracing state conditions in the
graph, you convert the graph into a limited-entry
decision table. Each column in the table represents a
test case.
6. The columns in the decision table are converted into
test cases.

1414
Click to edit Master
Cause-Effect Graphing
title style

• The identity function states that if a is 1, b is 1; else


b is 0.
• The not function states that if a is 1, b is 0, else b is
1.
• The or function states that if a or b or c is 1, d is 1;
else d is 0.
• The and function states that if both a and b are 1, c
is 1; else c is 0.

1515
Click to edit Master
Cause-Effect Graphing
title style

The character in column 1 must be an ‘‘A’’ or a ‘‘B.’’


The character in column 2 must be a digit. In this
situation, the file update is made. If the first character
is incorrect, message X12 is issued. If the second
character is not a digit, message X13 is issued.

• 1—character in column 1 is ‘‘A’’


• 2—character in column 1 is ‘‘B’’
• 3—character in column 2 is a digit

• 70—update made
• 71—message X12 is issued
• 72—message X13 is issued
1616
Click to edit Master
Cause-Effect Graphing
title style

• The E constraint states that it must always be true


that, at most, one of a and b can be 1 (a and b
cannot be 1 simultaneously).
• The I constraint states that at least one of a, b, and c
must always be 1 (a, b, and c cannot be 0
simultaneously).
• The O constraint states that one, and only one, of a
and b must be 1.
• The R constraint states that for a to be 1, b must be
1 (i.e., it is impossible for a to be 1 and b to be 0).
• The M constraint states that if effect a is 1, effect b
is forced to 0.

1717
Click to edit Master
Cause-Effect Graphing
title style

The character in column 1 must be an ‘‘A’’ or a ‘‘B.’’


The character in column 2 must be a digit. In this
situation, the file update is made. If the first character
is incorrect, message X12 is issued. If the second
character is not a digit, message X13 is issued.

• 1—character in column 1 is ‘‘A’’


• 2—character in column 1 is ‘‘B’’
• 3—character in column 2 is a digit

• 70—update made
• 71—message X12 is issued
• 72—message X13 is issued
1818
Click to edit Master
Cause-Effect Graphing
title style

Generation of a limited-entry decision table:


1. Select an effect to be the present (1) state.
2. Tracing back through the graph, find all
combinations of causes (subject to the constraints)
that will set this effect to 1.
3. Create a column in the decision table for each
combination of causes.
4. For each combination, determine the states of all
other effects and place these in each column.

1919
Click to edit Master
Cause-Effect Graphing
title style

To cause 7 = 0:

1 2 3 4 5&6
0 0 0 0 0, 0
1 0 0 0 1, 0
1 0 0 1 1, 0
1 0 1 0 1, 0
0 0 1 1 0, 1

2020
Click to
Error Guessing
edit Master title style

For the MTEST example:


• Does the program accept ‘‘blank’’ as an answer?
• A type-2 (answer) record appears in the set of type-
3 (student) records.
• A record without a 2 or 3 in the last column appears
as other than the initial (title) record.
• Two students have the same name or number.
• Since a median is computed differently depending on
whether there is an odd or an even number of items,
test the program for an even number of students and
an odd number of students.
• The number-of-questions field has a negative value.

2121
ClickStrategy
The to edit Master title style

1. If the specification contains combinations of input


conditions, start with cause-effect graphing.
2. In any event, use boundary value analysis.
Remember that this is an analysis of input and
output boundaries. The boundary value analysis
yields a set of supplemental test conditions, but as
noted in the section on cause-effect graphing, many
or all of these can be incorporated into the cause-
effect tests.
3. Identify the valid and invalid equivalence classes for
the input and output, and supplement the test cases
identified above, if necessary.
4. Use the error-guessing technique to add additional
test cases.

2222
ClickStrategy
The to edit Master title style

5. Examine the program’s logic with regard to the set


of test cases. Use the decision coverage, condition
coverage, decision/condition coverage, or multiple-
condition coverage criterion (the last being the most
complete). If the coverage criterion has not been met
by the test cases identified in the prior four steps,
and if meeting the criterion is not impossible (i.e.,
certain combinations of conditions may be impossible
to create because of the nature of the program), add
sufficient test cases to cause the criterion to be
satisfied.

2323
Click3to
Lab (White-Box
edit Master
Testing)
title style

• Check out a simple Python calculator here:


https://github.com/CoolJWB/Python-
Calculator/blob/master/calculator.py
• Find five minimum-size set of test cases each of which in turn
provides full (1) statement coverage, (2) decision coverage, (3)
condition coverage, (4) decision/condition coverage, and (5) multiple-
condition coverage for the simple Python calculator, respectively.
• Due: 10/22 Sun 24:00

2424
Click to edit Master title style

Thank You!

25

You might also like