Download - Black box testing

Transcript
Page 1: Black box testing
Page 2: Black box testing

Black box testing Black box tests focus on the

input/output behavior of the component

Black-box tests do not deal with the internal aspects of the component nor with the behavior or the structure of the components

Page 3: Black box testing

Equivalence testing Equivalence testing is a black box

testing technique that minimizes the number of test cases

Page 4: Black box testing

Equivalence testing The possible inputs are partitioned

into equivalence classes, a test case is selected for each class

The assumption of equivalence testing is that systems usually behave in similar ways for all members of a class

Page 5: Black box testing

Equivalence testing Equivalence testing consists of two

steps: identification of the equivalence classes selection of the test inputs

Page 6: Black box testing

Equivalence classes Coverage: every possible input

belongs to one of the equivalence classes

Disjointedness: no input belongs to more than one equivalence class

I.e., partition

Page 7: Black box testing

Equivalence classes Representation: if the execution

demonstrates an error when a particular member of a equivalence class is used as input, then the same error can be detected by using any other member of the class as input.

Page 8: Black box testing

Test cases For each equivalence class, at least

two pieces of data are selected a typical input, which exercises the

common case an invalid input, which exercises the

exception handling capabilities of the component

Page 9: Black box testing

Boundary testing Boundary testing is a special case of

equivalence testing and focuses on the conditions at the boundary of the equivalence classes

Page 10: Black box testing

Boundary testing The assumption behind boundary

testing is that developers often overlook special cases at the boundary of the equivalence classes

E.g., Empty strings Year 2000 (millennium bug) …

Page 11: Black box testing

Int converter (again) A function converts a sequence of

chars in an integer number. The sequence can start with a ‘-‘

(negative number). The integer number must be in the range

minint = -32768 to maxint = 32767. The function signals an error if the

sequence of chars is not allowed The sequence must be <= 6 chars

Page 12: Black box testing

Int converter (again)1. Define equivalence classes, and

related boundary condition2. For each class, define at least one

test case

Page 13: Black box testing

Criterion Input is a decimal number (well

formed integer) Valid: may start with –, no characters

that are not digits Invalid: … Boundary: Starting “+”? Blanks?

Page 14: Black box testing

Criterion Length of string, number of

characters Valid: <= 6 Invalid: > 6 Boundary: 6, 0

Page 15: Black box testing

Criterion Range of number in output

Valid: <= maxint, >= minint Invalid: > maxint, < minint Boundary: maxint, minint

Page 16: Black box testing

Calendar BBConsider a method that returns the number of days in a month, given the month and year. 

public class MyGregorianCalendar {public static int getNumDaysInMonth(int x, int y){

...}

The month and the year are specified as integers. By convention, 1 represents the month of January, 2 the month of February, and so on. The range of valid inputs for the year is 0 to maxInt.

1.define equivalence classes, and related boundary condition2.for each class, define at least one test case

Page 17: Black box testing

Classes for month parameter Three equivalence classes:

months with 31 days (i.e., 1, 3, 5, 7, 8, 10, 12)

months with 30 days (i.e., 4, 6, 9, 11) February, which can have 28 or 29 days

Nonpositive integers and integers larger than 12 are invalid values

Page 18: Black box testing

Classes for year parameter Two equivalence classes:

leap years non–leap years

Negative integers are invalid values

Page 19: Black box testing

Selected valid inputs

Page 20: Black box testing

Additional boundary cases

Page 21: Black box testing

Equivalence classes definition An interval condition will have classes for

Valid input within the interval Invalid input less than the minimum Invalid input greater than the maximum Valid input close the boundaries

A single value condition will have classes for: The valid value Invalid values less than the value Invalid values greater than the value

Page 22: Black box testing

Equivalence classes definition A discrete set condition will have

classes for: Each value in the set A value not belonging to the set

A boolean value condition will have classes for: TRUE value FALSE value

Page 23: Black box testing

Parallelogram The function parallelogram(int x1,

int x2, int x3, int x4, int y1, int y2, int y3, int y4) calculate the area of a parallelogram.

Page 24: Black box testing

Parallelogram Requirements

area is always strictly > 0 The parallelogram should stay in the

first quadrant of the Cartesian plan

Define equivalence classes and tests

Page 25: Black box testing

Criteria Pair sides parallelism Pair same sides length Position (1st quadrant) Area > 0