Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software...

96
Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4

Transcript of Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software...

Page 1: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Black-Box Testing Techniques I

Prepared by

Stephen M. Thebaut, Ph.D.

University of Florida

Software Testing and Verification

Lecture 4

Page 2: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Definition of Black-Box Testing

• Testing based solely on analysis of requirements (specification, user documentation, etc.).

• Also know as functional testing.

• Black-box testing concerns techniques for designing tests; it is not a “level” of testing.

• Black-box techniques apply to all levels of testing (e.g., unit, component, product, and system).

Page 3: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Definition of Black-Box Testing

• Testing based solely on analysis of requirements (specification, user documentation, etc.).

• Also know as functional testing.

• Black-box testing concerns techniques for designing tests; it is not a “level” of testing.

• Black-box techniques apply to all levels of testing (e.g., unit, component, product, and system).

Page 4: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Definition of Black-Box Testing

• Testing based solely on analysis of requirements (specification, user documentation, etc.).

• Also know as functional testing.

• Black-box testing concerns techniques for designing tests; it is not a “level” of testing.

• Black-box techniques apply to all levels of testing (e.g., unit, component, product, and system).

Page 5: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Definition of Black-Box Testing

• Testing based solely on analysis of requirements (specification, user documentation, etc.).

• Also know as functional testing.

• Black-box testing concerns techniques for designing tests; it is not a “level” of testing.

• Black-box techniques apply to all levels of testing (e.g., unit, component, product, and system).

Page 6: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Design Techniques Considered

• Partition testing

• Combinatorial Approaches

• Boundary Value Analysis

• Intuition & Experience

Page 7: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Design Techniques Considered

• Partition testing

• Combinatorial Approaches

• Boundary Value Analysis

• Intuition & Experience

Page 8: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Design Techniques Considered

• Partition testing

• Combinatorial Approaches

• Boundary Value Analysis

• Intuition & Experience

Page 9: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Design Techniques Considered

• Partition testing

• Combinatorial Approaches

• Boundary Value Analysis

• Intuition & Experience

Page 10: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing

• Also known as input space partitioning and equivalence partitioning.

• Can be thought of as exhaustive testing Las Vegas style...

• Idea is to partition the program’s input space based on a (small) number of equivalence classes such that, according to the specification, every element of a given partition would be “handled” (i.e., mapped to an output) “in the same manner.”

Page 11: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing

• Also known as input space partitioning and equivalence partitioning.

• Can be thought of as exhaustive testing Las Vegas style...

• Idea is to partition the program’s input space based on a (small) number of equivalence classes such that, according to the specification, every element of a given partition would be “handled” (i.e., mapped to an output) “in the same manner.”

Page 12: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing

• Also known as input space partitioning and equivalence partitioning.

• Can be thought of as exhaustive testing Las Vegas style...

• Idea is to partition the program’s input space based on a (small) number of equivalence classes such that, according to the specification, every element of a given partition is “handled” (e.g., mapped to an output) “in the same manner.”

Page 13: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing (cont’d)

• If the program happens to be implemented in such a way that being “handled in the same manner” means that either

– every element of a partition is mapped to a correct output, or

– every element of a partition is mapped to an incorrect output,

then testing the program with just one element from each partition would be tantamount to exhaustive testing.

Page 14: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing (cont’d)

• Two types of equivalence classes are identified: valid (corresponding to inputs deemed valid from the specification) and invalid (corresponding to inputs deemed erroneous from the specification)

• In most multi-input cases, classes for individual inputs must be combined in some manner to partition the input space. (E.g., see City Tax Specification below.)

Page 15: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing (cont’d)

• Two types of equivalence classes are identified: valid (corresponding to inputs deemed valid from the specification) and invalid (corresponding to inputs deemed erroneous from the specification)

• In most multi-input cases, classes for individual inputs must be combined in some manner to partition the input space. (E.g., see City Tax Specification below.)

Page 16: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing (cont’d)

• However, it is sometimes possible and convenient to identify multivariate classes which partition an input space directly.

• Consider the following specification…

Page 17: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing (cont’d)

• However, it is sometimes possible and convenient to identify multivariate classes which partition an input space directly.

• Consider the following specification…

Page 18: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing Example

• Program Specification:

An ordered pair of numbers, (x, y), are input and a message is output stating whether they are in ascending order, descending order, or equal. If the input is other than an ordered pair of numbers, an error message is output.

Page 19: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing Example (cont’d)

• Equivalence Classes:

{ (x, y) | x<y } (V)

{ (x, y) | x>y } (V)

{ (x, y) | x=y } (V)

{ input is other than an ordered

pair of numbers } (I)

Valid classes

Invalid class

Page 20: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Valid (x, y) Input Space

x = y

x < y

x > y

Page 21: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partition Testing Example (cont’d)

• In this case, being “handled in the same manner” clearly relates directly to the relationship between inputs x and y, so equivalence classes are more naturally defined in terms of (x,y) pairs.

Page 22: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Sample Program Design

• Conceptually, would the underlying assumption of partition testing hold for these classes if the following program design was employed?

if (input is other than an ordered pair of numbers) then output(“invalid input”)

elseif x<y then output(“ascending order”)else if x>y then output(“ascending order”) else

output(“equal”)

Page 23: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Identifying and Representing Test Cases

• Test case design requirements are often represented (documented) using a “test case COVERAGE MATRIX.”

• Columns in the matrix represent templates for test case inputs (and in some cases expected results).

• Rows represent the design rationale for each test case.

Page 24: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Identifying and Representing Test Cases

• Test case design requirements are often represented (documented) using a “test case COVERAGE MATRIX.”

• Columns in the matrix represent templates for test case inputs (and in some cases expected results).

• Rows represent the design rationale for each test case.

Page 25: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Identifying and Representing Test Cases

• Test case design requirements are often represented (documented) using a “test case COVERAGE MATRIX.”

• Columns in the matrix represent templates for test case inputs (and in some cases expected results).

• Rows represent the design rationale for each test case.

Page 26: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

A Test Case Coverage Matrix

EQUIVALENCE

CLASSES

TEST CASES1 2 3 4

{ (x, y) | x>y } (V)

V

{ (x, y) | x<y } (V)

V

{ (x, y) | x=y } (V)

V

{ other } (I) I†† Rule of thumb: include test cases that cover invalid classes one at a time to avoid “masking of errors.”

Page 27: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations

• In the example above, (x, y) input pairs were considered as a unit, yielding a set of disjoint classes partitioning the two-dimensional x, y (valid) input space.

• For more complex specifications, classes are often identified for INDIVIDUAL input variables, or even INDIVIDUAL ATTRIBUTES of individual input variables, yielding sets of possibly overlapping classes. For example...

Page 28: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations

• In the example above, (x, y) input pairs were considered as a unit, yielding a set of disjoint classes partitioning the two-dimensional x, y (valid) input space.

• For more complex specifications, classes are often identified for INDIVIDUAL input variables, or even INDIVIDUAL ATTRIBUTES of individual input variables, yielding sets of possibly overlapping classes. For example...

Page 29: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations (cont’d)Part of a More Complex Program Specification:

Three numbers, x, y, and z, are input. If x is a whole number and less than 40, and if y is non-negative, the output is z+(y/x). If x is greater than or equal to 40, or if y is positive, or if z is odd and at least as large as x, then the output is...

Page 30: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations (cont’d)• (Some) Valid Equivalence Classes:

– { x | x is a whole number } (V)

– { x | x < 40 } (V), { x | x ≥ 40 } (V)

– { y | y = 0 } (V), { y | y > 0 } (V)

– { z | z is odd } (V)

– { (x, z) | z x } (V)

. . .

Page 31: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations (cont’d)• In such cases, a strategy for identifying

appropriate COMBINATIONS of classes must be employed.

• A number of “combinatorial approaches” (including Cause-Effect Analysis) will be considered shortly.

• Clearly, the most critical issue in partition testing is the choice of an “equivalence relation” that defines the classes used.

Page 32: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations (cont’d)• In such cases, a strategy for identifying

appropriate COMBINATIONS of classes must be employed.

• A number of “combinatorial approaches” (including Cause-Effect Analysis) will be considered shortly.

• Clearly, the most critical issue in partition testing is the choice of an “equivalence relation” that defines the classes used.

Page 33: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Dealing with Complex Multiple-Input Situations (cont’d)• In such cases, a strategy for identifying

appropriate COMBINATIONS of classes must be employed.

• A number of “combinatorial approaches” (including Cause-Effect Analysis) will be considered shortly.

• Clearly, the most critical issue in partition testing is the choice of an “equivalence relation” that defines the classes used.

Page 34: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes

• “Must Be” Situations

– “First character must be a letter.”

– Identify one valid and one invalid class:

{1st char letter } (V),

{1st char not letter} (I)

Page 35: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes

• “Must Be” Situations

– “First character must be a letter.”

– Identify one valid and one invalid class:

{1st char letter } (V),

{1st char not letter} (I)

Page 36: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes

• “Must Be” Situations

– “First character must be a letter.”

– Identify one valid and one invalid class:

{1st char letter } (V),

{1st char not letter} (I)

Page 37: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes

• “Must Be” Situations

– “First character must be a letter.”

– Identify one valid and one invalid class:

{1st char letter } (V),

{1st char not letter} (I)

Page 38: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Range of Values” Situations

– “Input HOURS will range in value from 0 to 40.”

– Identify one valid and two invalid classes:

{ HOURS [0,40] } (V),

{ HOURS < 0 } (I),

{ HOURS > 40 } (I)

Page 39: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Range of Values” Situations

– “Input HOURS will range in value from 0 to 40.”

– Identify one valid and two invalid classes:

{ HOURS [0,40] } (V),

{ HOURS < 0 } (I),

{ HOURS > 40 } (I)

Page 40: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Range of Values” Situations

– “Input HOURS will range in value from 0 to 40.”

– Identify one valid and two invalid classes:

{ HOURS [0,40] } (V),

{ HOURS < 0 } (I),

{ HOURS > 40 } (I)

Page 41: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Range of Values” Situations

– “Input HOURS will range in value from 0 to 40.”

– Identify one valid and two invalid classes:

{ HOURS [0,40] } (V),

{ HOURS < 0 } (I),

{ HOURS > 40 } (I)

Page 42: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Possible Differences” Situations

– “For HOURS 20, output ‘Low’; for HOURS > 20, output ‘HIGH’."

– If the specification suggests that values in a class may be handled differently, divide the class accordingly. { HOURS [0,40] } (V) becomes:

{ HOURS [0,20]} (V),

{ HOURS (20,40] } (V)

Page 43: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Possible Differences” Situations

– “For HOURS 20, output ‘Low’; for HOURS > 20, output ‘HIGH’."

– If the specification suggests that values in a class may be handled differently, divide the class accordingly. { HOURS [0,40] } (V) becomes:

{ HOURS [0,20]} (V),

{ HOURS (20,40] } (V)

Page 44: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Possible Differences” Situations

– “For HOURS 20, output ‘Low’; for HOURS > 20, output ‘HIGH’."

– If the specification suggests that values in a class may be handled differently, divide the class accordingly. { HOURS [0,40] } (V) becomes:

{ HOURS [0,20]} (V),

{ HOURS (20,40] } (V)

Page 45: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some Simple Heuristics for Identifying Equivalence Classes (cont’d)• “Possible Differences” Situations

– “For HOURS 20, output ‘Low’; for HOURS > 20, output ‘HIGH’."

– If the specification suggests that values in a class may be handled differently, divide the class accordingly. { HOURS [0,40] } (V) becomes:

{ HOURS [0,20]} (V),

{ HOURS (20,40] } (V)

Page 46: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Another Partition Testing Example

• Identify disjoint sets of classes for each input variable associated with the following program specification fragment.

• You may detect some “incompleteness” problems with the specification…

Page 47: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Another Partition Testing Example

• Identify disjoint sets of classes for each input variable associated with the following program specification fragment.

• You may detect some “incompleteness” problems with the specification…

Page 48: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 1:

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than

$50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 49: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 1:

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than

$50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 50: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Equivalence Classes for City Tax Specification 1:

• Res?

– { yes } (V)

– { no } (V)

– { other } (I)

• Gross_Pay

– [0, 30K] (V)

– (30K,50K] (V)

– (50K, MAX] (V)

– < 0 (I)

– > MAX (I)

Note that program behaviors associated with invalid inputs are not specified!

Page 51: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Two-Dimensional (Valid) Input Space

If we partition the space comprised of these classes based solely on the specified outputs, what would the result be?

1% 5% 15%

1% 1% 1%

yes

no

Gross_Pay

30K (30K, 50K] > 50K

Res?

Page 52: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Two-Dimensional (Valid) Input Space

If we partition the space comprised of these classes based solely on the specified outputs, what would the result be?

1% 5% 15%

1% 1% 1%

yes

no

Gross_Pay

30K (30K, 50K] > 50K

Res?

Page 53: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

Page 54: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

Page 55: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

Page 56: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

Page 57: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

Page 58: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on Specified Output

Would you be comfortable with the degree of coverage afforded by choosing ONE test case from each of these 3 partitions? Why or why not?

5% 15%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1%

(“Weak Equivalence Class Testing”)

Page 59: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

The “Brute-Force” Approach

We could “hedge our bet” by associating a sep-arate partition with every (feasible) combi-nation of classes from the sets:

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

What are the pros and cons of this approach?

Page 60: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

The “Brute-Force” Approach

We could “hedge our bet” by associating a sep-arate partition with every (feasible) combi-nation of classes from the sets:

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

What are the pros and cons of this approach?

Page 61: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

The “Brute-Force” Approach

We could “hedge our bet” by associating a sep-arate partition with every (feasible) combi-nation of classes from the sets:

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

(“Strong Equivalence Class Testing”)

What are the pros and cons of this approach?

Page 62: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

The “Brute-Force” Approach

We could “hedge our bet” by associating a sep-arate partition with every (feasible) combi-nation of classes from the sets:

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

(“Strong Equivalence Class Testing”)

What are the pros and cons of this approach?

Page 63: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

The “Brute-Force” Approach (cont’d)

• The “brute-force” approach of specifying a test case for each (feasible) combination of classes (i.e., for each element in the Cartesian product of the classes associated with each variable) is sometimes referred to as “Strong Equivalence Class Testing.”

• In contrast, “Weak Equivalence Class Testing” requires only that all classes are covered. (The minimum number of cases needed will always be the largest number of disjoint classes associated with a single variable.)†

† Note that, as illustrated, covering partitions identified solely on the basis of specified outputs ≠> weak equivalence class testing.

Page 64: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Strong and Weak Equivalence Class Testing

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

Strong:

Weak:

Page 65: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs• An alternative to both the strong (“brute-force”)

and weak equivalence class testing approaches is to consider how the specification implies that inputs are mapped to outputs.

• This amounts to choosing an equivalence relation by “second-guessing” how the mapping may actually be implemented based on how the specification is written.

• Recall from our specification…

Page 66: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Implied Mapping of Inputs to Outputs

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 67: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to OutputsWhat does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 68: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Implied Mapping of Inputs to Outputs

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 69: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%Res?

yes

no

Gross_Pay

30K (30K, 50K] > 50K

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Page 70: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Implied Mapping of Inputs to Outputs

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 71: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Res?yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 72: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Implied Mapping of Inputs to Outputs

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 73: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Res?yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 74: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Implied Mapping of Inputs to Outputs

A non-resident will pay 1% of the gross pay in city tax.

Residents pay on the following scale:

- If gross pay is no more than $30,000, the tax is 1%.

- If gross pay is more than $30,000, but no more than $50,000, the tax is 5%.

- If gross pay is more than $50,000, the tax is 15%.

Page 75: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%

What are the pros and cons of this approach?

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Res?yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 76: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%

What are the pros and cons of this approach?

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Res?yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 77: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Partitioning Based on the Implied Mapping of Inputs to Outputs

1% 5% 15%

1%

What are the pros and cons of this approach?

What does the logical mapping of inputs to outputs implied by the specification suggest about how the input space should be partitioned?

Res?yes

no

Gross_Pay

30K (30K, 50K] > 50K

Page 78: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

If gross pay is no more than $30,000, the tax is 1%.

If gross pay is more than $30,000, but no more than $50,000 the tax is 1% for non-residents and 5% for residents.

If gross pay is more than $50,000, the tax is 1% for nonresidents and 15% for residents.

Page 79: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2 (cont’d)

What does the logical mapping of inputs to outputs implied by this specification suggest about how the input space should be partitioned?

1% 5% 15%

1% 1% 1%Res?

yes

no

Gross_Pay 30K (30K, 50K] > 50K

Page 80: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

If gross pay is no more than $30,000, the tax is 1%.

If gross pay is more than $30,000, but no more than $50,000 the tax is 1% for non-residents and 5% for residents.

If gross pay is more than $50,000, the tax is 1% for nonresidents and 15% for residents.

Page 81: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2 (cont’d)

What does the logical mapping of inputs to outputs implied by this specification suggest about how the input space should be partitioned?

5% 15%

1% 1%1%Res?

yes

no

Gross_Pay 30K (30K, 50K] > 50K

Page 82: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

If gross pay is no more than $30,000, the tax is 1%.

If gross pay is more than $30,000, but no more than $50,000 the tax is 1% for non-residents and 5% for residents.

If gross pay is more than $50,000, the tax is 1% for nonresidents and 15% for residents.

Page 83: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2 (cont’d)

What does the logical mapping of inputs to outputs implied by this specification suggest about how the input space should be partitioned?

5% 15%

1% 1%1%Res?

yes

no

Gross_Pay 30K (30K, 50K] > 50K

Page 84: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2

The first input is a yes/no response to the question “Do you reside within the city?” The second input is gross pay for the year in question.

If gross pay is no more than $30,000, the tax is 1%.

If gross pay is more than $30,000, but no more than $50,000 the tax is 1% for non-residents and 5% for residents.

If gross pay is more than $50,000, the tax is 1% for nonresidents and 15% for residents.

Page 85: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2 (cont’d)

What does the logical mapping of inputs to outputs implied by this specification suggest about how the input space should be partitioned?

5% 15%

1% 1%1%Res?

yes

no

Gross_Pay 30K (30K, 50K] > 50K

Page 86: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

City Tax Specification 2 (cont’d)

What does the logical mapping of inputs to outputs implied by this specification suggest about how the input space should be partitioned?

5% 15%

1% 1%1%Res?

yes

no

Gross_Pay 30K (30K, 50K] > 50K

Page 87: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions

• In general, the connection between partition testing and exhaustive testing is tenuous, at best.

• Partitioning a complex, multi-dimensional input space based solely on differences in specified output behavior can be risky.

Page 88: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions

• In general, the connection between partition testing and exhaustive testing is tenuous, at best.

• Partitioning a complex, multi-dimensional input space based solely on differences in specified output behavior can be risky.

Page 89: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• The “brute-force” approach of associating a separate partition with every (feasible) combination of classes (“strong equivalence class testing”) provides excellent black-box coverage, but is impractical when the number of inputs and associated sets of classes is large.

• “Weak equivalence class testing” ensures that all classes are covered, but not all (feasible) combinations of classes

Page 90: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• The “brute-force” approach of associating a separate partition with every (feasible) combination of classes (“strong equivalence class testing”) provides excellent black-box coverage, but is impractical when the number of inputs and associated sets of classes is large.

• “Weak equivalence class testing” ensures that all classes are covered, but does not ensure coverage of all (feasible) combinations of classes.

Page 91: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• Choosing an equivalence relation by “second-guessing” how the mapping of inputs to outputs may be imple-mented based on how the specification is written seems more in keeping with:

...according to the specification, every elementof a given partition would be “handled” (e.g.,mapped to an output) “in the same manner.”

But does test case coverage of the resultant partitions guarantee:

1.Strong equivalence class testing? 2.Weak equivalence class testing?

Page 92: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• Choosing an equivalence relation by “second-guessing” how the mapping of inputs to outputs may be imple-mented based on how the specification is written seems more in keeping with:

...according to the specification, every elementof a given partition would be “handled” (e.g.,mapped to an output) “in the same manner.”

But does test case coverage of the resultant partitions guarantee:

1.Strong equivalence class testing? Obviously not.

2.Weak equivalence class testing?

Page 93: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• Choosing an equivalence relation by “second-guessing” how the mapping of inputs to outputs may be imple-mented based on how the specification is written seems more in keeping with:

...according to the specification, every elementof a given partition would be “handled” (e.g.,mapped to an output) “in the same manner.”

But does test case coverage of the resultant partitions guarantee:

1.Strong equivalence class testing? Obviously not.

2.Weak equivalence class testing? No.

Page 94: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Some conclusions (cont’d)

• Choosing an equivalence relation by “second-guessing” how the mapping of inputs to outputs may be imple-mented based on how the specification is written seems more in keeping with:

...according to the specification, every elementof a given partition would be “handled” (e.g.,mapped to an output) “in the same manner.”

But does test case coverage of the resultant partitions guarantee:

1.Strong equivalence class testing? Obviously not.

2.Weak equivalence class testing? No.†

† Try writing a “City Tax Specification 3” that proves this.

Page 95: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Coming Up Next…

• The combinatorial approach considered next, Cause-Effect Analysis, allows for the systematic (and with appropriate tool support, automatic) partitioning of a multi-dimensional input space for different levels of coverage.

Page 96: Black-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 4.

Black-Box Testing Techniques I

Prepared by

Stephen M. Thebaut, Ph.D.

University of Florida

Software Testing and Verification

Lecture 4