Black box testing Black box tests focus on


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

Equivalence testing § Equivalence testing is a black box testing technique that minimizes the number of test cases

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

Equivalence testing § Equivalence testing consists of two steps: w identification of the equivalence classes w selection of the test inputs

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

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.

Test cases § For each equivalence class, at least two pieces of data are selected w a typical input, which exercises the common case w an invalid input, which exercises the exception handling capabilities of the component

Boundary testing § Boundary testing is a special case of equivalence testing and focuses on the conditions at the boundary of the equivalence classes

Boundary testing § The assumption behind boundary testing is that developers often overlook special cases at the boundary of the equivalence classes § E. g. , w Empty strings w Year 2000 (millennium bug) w…

Int converter (again) § A function converts a sequence of chars in an integer number. w The sequence can start with a ‘-‘ (negative number). w The integer number must be in the range minint = -32768 to maxint = 32767. w The function signals an error if the sequence of chars is not allowed w The sequence must be <= 6 chars

Int converter (again) 1. Define equivalence classes, and related boundary condition 2. For each class, define at least one test case

Criterion § Input is a decimal number (well formed integer) w Valid: may start with –, no characters that are not digits w Invalid: … w Boundary: Starting “+”? Blanks?

Criterion § Length of string, number of characters w Valid: <= 6 w Invalid: > 6 w Boundary: 6, 0

Criterion § Range of number in output w Valid: <= maxint, >= minint w Invalid: > maxint, < minint w Boundary: maxint, minint

Calendar BB Consider a method that returns the number of days in a month, given the month and year. public class My. Gregorian. Calendar { public static int get. Num. Days. In. Month(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 max. Int. 1. 2. define equivalence classes, and related boundary condition for each class, define at least one test case

Classes for month parameter § Three equivalence classes: w months with 31 days (i. e. , 1, 3, 5, 7, 8, 10, 12) w months with 30 days (i. e. , 4, 6, 9, 11) w February, which can have 28 or 29 days § Nonpositive integers and integers larger than 12 are invalid values

Classes for year parameter § Two equivalence classes: w leap years w non–leap years § Negative integers are invalid values

Selected valid inputs

Additional boundary cases

Equivalence classes definition § An interval condition will have classes for w w 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: w The valid value w Invalid values less than the value w Invalid values greater than the value

Equivalence classes definition § A discrete set condition will have classes for: w Each value in the set w A value not belonging to the set § A boolean value condition will have classes for: w TRUE value w FALSE value

Parallelogram § The function parallelogram(int x 1, int x 2, int x 3, int x 4, int y 1, int y 2, int y 3, int y 4) calculate the area of a parallelogram.

Parallelogram § Requirements w area is always strictly > 0 w The parallelogram should stay in the first quadrant of the Cartesian plan § Define equivalence classes and tests

Criteria § § Pair sides parallelism Pair same sides length Position (1 st quadrant) Area > 0
- Slides: 25