# Black box testing

date post

23-Feb-2016Category

## Documents

view

46download

0

Embed Size (px)

description

### Transcript of Black box testing

Black box testingBlack box tests focus on the input/output behavior of the componentBlack-box tests do not deal with the internal aspects of the component nor with the behavior or the structure of the components

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

Equivalence testingThe possible inputs are partitioned into equivalence classes, a test case is selected for each classThe assumption of equivalence testing is that systems usually behave in similar ways for all members of a class

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

Equivalence classesCoverage: every possible input belongs to one of the equivalence classesDisjointedness: no input belongs to more than one equivalence class

I.e., partition

Equivalence classesRepresentation: 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 casesFor each equivalence class, at least two pieces of data are selecteda typical input, which exercises the common casean invalid input, which exercises the exception handling capabilities of the component

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

Boundary testingThe assumption behind boundary testing is that developers often overlook special cases at the boundary of the equivalence classesE.g., Empty stringsYear 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 allowedThe sequence must be
Int converter (again)Define equivalence classes, and related boundary conditionFor each class, define at least one test case

CriterionInput is a decimal number (well formed integer)Valid: may start with , no characters that are not digitsInvalid: Boundary: Starting +? Blanks?

CriterionLength of string, number of charactersValid: 6Boundary: 6, 0

CriterionRange of number in outputValid: = minintInvalid: > maxint, < minintBoundary: maxint, minint

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.

define equivalence classes, and related boundary conditionfor each class, define at least one test case

Classes for month parameterThree 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 daysNonpositive integers and integers larger than 12 are invalid values

Classes for year parameterTwo equivalence classes:leap years nonleap yearsNegative integers are invalid values

Selected valid inputs

Additional boundary cases

Equivalence classes definitionAn interval condition will have classes forValid input within the intervalInvalid input less than the minimumInvalid input greater than the maximumValid input close the boundariesA single value condition will have classes for:The valid valueInvalid values less than the valueInvalid values greater than the value

Equivalence classes definitionA discrete set condition will have classes for:Each value in the setA value not belonging to the setA boolean value condition will have classes for:TRUE valueFALSE value

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

ParallelogramRequirementsarea is always strictly > 0The parallelogram should stay in the first quadrant of the Cartesian plan

Define equivalence classes and tests

CriteriaPair sides parallelismPair same sides lengthPosition (1st quadrant)Area > 0

*