1.17k likes | 3.29k Views
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.
E N D
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: • identification of the equivalence classes • 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 • a typical input, which exercises the common case • 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., • Empty strings • Year 2000 (millennium bug) • …
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
Int converter (again) • Define equivalence classes, and related boundary condition • For each class, define at least one test case
Criterion • Input is a decimal number (well formed integer) • Valid: may start with –, no characters that are not digits • Invalid: … • Boundary: Starting “+”? Blanks?
Criterion • Length of string, number of characters • Valid: <= 6 • Invalid: > 6 • Boundary: 6, 0
Criterion • Range of number in output • Valid: <= maxint, >= minint • Invalid: > maxint, < minint • Boundary: maxint, minint
Calendar BB Consider a method that returns the number of days in a month, given the month and year. publicclassMyGregorianCalendar { publicstaticintgetNumDaysInMonth(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. • define equivalence classes, and related boundary condition • for each class, define at least one test case
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
Classes for year parameter • Two equivalence classes: • leap years • non–leap years • Negative integers are invalid values
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
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
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.
Parallelogram • Requirements • area is always strictly > 0 • 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 (1st quadrant) • Area > 0