# Testing

CISS

Overview

• Black-box testing (or functional testing):

• Equivalence partitioning • Boundary value analysis • Cause-effect graphing • Behavioural testing • Random testing • Error guessing etc… Domain analysis

• How to use black-box and white-box testing in combination • Basics : heuristics and experience

CISS

Black box testing

requirements output

input events

SUT y domain testing

x CISS

Black-box: Three major approaches

• Analysis of the input/output domain of the program: • Analysis of the observable black-box behaviour: • Heuristics ‘interesting’ subsets

• Leads to a logical partitioning of the input/output domain into • Leads to a flow-graph-like model, which enables application of techniques from the white-box world (on the black-box model)

• Techniques like risk analysis, random input, stress testing

CISS

Types of Testing

CISS

V - Model

acceptance test spec

requirements

acceptance test

system test spec

specification

system test

architecture spec

integration test spec

integration test

module test spec

detailed design

unit test spec

module test

implementation code

unit-test

CISS

Black-box : Equivalence Partitioning

• Divide all possible inputs into classes (partitions) such that • There is a finite number of input equivalence classes • You may reasonably assume that • the program behaves analogously for inputs in the same class • a test with a representative value from a class is sufficient • if representative detects fault then other class members will detect the same fault

CISS

Black-box : Equivalence Partitioning

Strategy :

• Identify input equivalence classes

• Based on conditions on inputs / outputs in specification / description • Both valid and invalid input equivalence classes • Based on heuristics and experience • “input x in [1..10]” • “enumeration A, B, C • ……..

→ →

classes : x < 1, 1 ≤ x ≤ 10, x > 10 classes : A, B, C, not{A,B,C,}

•

Define one / couple of test cases for each class • Test cases that cover valid eq. classes • Test cases that cover at most one invalid eq. class

CISS

Example : Equivalence Partitioning

• Test a function for calculation of absolute value of an integer • Equivalence classes : Condition nr of inputs Input type particular abs Valid eq. classes 1 integer < 0, >= 0 Invalid eq. Classes 0, > 1 non-integer

• Test cases :

x = -10, x = “XYZ”, x = 100 x=x = 10 20

CISS

A Self-Assessment Test [Myers]

“A program reads three integer values. The three values are interpreted as representing the lengths of the sides of a triangle. The program prints a message that states whether the triangle is scalene (uligesidet), isosceles (ligebenet) , or equilateral (ligesidet).”

•Write a set of test cases to test this program.

CISS

A Self-Assessment Test [Myers]

Test cases for: 1. valid scalene triangle ? 2. valid equilateral triangle ? 3. valid isosceles triangle ? 4. 3 permutations of previous ? 5. side = 0 ? 6. negative side ? 7. one side is sum of others ? 8. 3 permutations of previous ? 9. one side larger than sum of others ? 10. 3 permutations of previous ? 11. all sides = 0 ? 12. non-integer input ? 13. wrong number of values ? 14. for each test case: is expected output specified ? 15. check behaviour after output was produced ?

CISS

Example : Equivalence Partitioning

• Test a program that computes the sum of the first value integers as long as this sum is less than maxint. Otherwise an error should be reported. If value is negative, then it takes the absolute value

• Formally:

Given integer inputs maxint and value compute result :

|value|

result =

∑k

K=0

if this

Please join StudyMode to read the full document