Designing Tests from Observable Behaviour

When you test a booking form, a calculator, or a software service, you can choose inputs and check results using its published requirements. Black-box testing evaluates externally observable behaviour against a specification without using the internal implementation to select the tests. At this level, your central decisions are which inputs deserve separate tests and what each test should produce. Equivalence partitions and boundary values give you systematic ways to make those decisions.

Start with the specified behaviour

A useful test records an input, any required starting conditions, and an expected observable result. That result might be a returned value, an acceptance message, or a rejection that leaves stored information unchanged. A test oracle supplies the expectation; here, it is the specification.


Determine the expectation before comparing it with the software's actual behaviour. Otherwise, you risk treating whatever the software happens to do as correct. If a requirement is ambiguous about an endpoint or an error response, clarify that uncertainty before assigning a definite expected result.



Group inputs by expected treatment

An equivalence partition is a group of inputs that the specification suggests should receive the same relevant treatment. You select representatives from these groups to reduce the number of tests while preserving meaningful behavioural differences.


Example: A reservation service accepts an integer number of nights from 4 through 10, inclusive, and rejects other integers. Its input domain has three useful partitions:


Input condition

Expected treatment

Representative

Fewer than 4 nights

Reject

1 night

From 4 through 10 nights

Accept

7 nights

More than 10 nights

Reject

15 nights


The two rejected regions remain separate because the software could check the lower limit correctly while mishandling the upper limit. If accepted inputs receive different specified prices or permissions, those differences can justify further partitions.


Three regions of integer inputs surround an accepted range from 4 through 10.


A representative provides evidence about its partition; passing that test does not establish that every member behaves correctly. Partitioning is a reasoned selection method, not a proof that the implementation treats all grouped inputs identically.

Probe the boundaries deliberately

Boundary-value analysis targets transitions between specified behaviours. An incorrect comparison can accept one extra value or reject an allowed endpoint, even when an ordinary interior value works.


For an inclusive integer range from aa through bb, one useful selection rule tests immediately below, at, and immediately above each limit:


B(a,b)={a−1, a, a+1, b−1, b, b+1}.B(a,b)=\{a-1,\ a,\ a+1,\ b-1,\ b,\ b+1\}.


For the reservation rule, this gives 3, 4, 5, 9, 10, and 11 nights. Expect rejection at 3 and 11, and acceptance at the other four values. The endpoint values reveal whether the specified limits are inclusive.


The selection rule assumes integer inputs with a step of one. For decimal inputs, identify the supported precision before choosing neighbouring values. Also remove duplicate inputs when a narrow range makes selections overlap.



With several fields, a useful focused test changes one field while keeping the others at valid reference values. This makes an unexpected rejection easier to interpret. Testing combinations can provide additional evidence when the requirements involve relationships between fields.

What to remember

  • Derive inputs and expected results from the specification.
  • Represent each meaningful valid and invalid partition.
  • Test limits and their neighbours using the input's supported step.
  • Remove duplicate cases and distinguish test evidence from exhaustive verification.

Example: Testing a Library Loan Duration

A library's loan service receives an integer duration in days. It must accept durations from 2 through 14 days, inclusive, and reject every other integer. No other fields or restrictions apply. A test case records the submitted input and its expected observable outcome.


Use the specification to design tests before examining the service's responses.


a) Identify the input partitions and choose one representative from each.


First, locate the two transitions in specified behaviour: the minimum of 2 days and the maximum of 14 days. Because inputs are integers, the region below the minimum ends at ________, and the region above the maximum starts at ________.


The three partitions are therefore:

  • Durations of 1 day or less: reject.
  • Durations from 2 through 14 days: accept.
  • Durations of 15 days or more: reject.

Choose 0 days, 8 days, and 20 days as representatives. Their expected outcomes are rejection, acceptance, and rejection, respectively. The final representative set contains 3 test cases, one for each partition. Keeping the two rejected regions separate allows each limit to be checked independently.


b) Select the integer immediately below, at, and immediately above each limit. State every input and its expected outcome.


For the lower limit, subtract and add the one-day input step:


2−1=1 day,2 days,2+1=3 days.2-1=1\ \text{day},\qquad 2\ \text{days},\qquad 2+1=3\ \text{days}.


The value immediately above the lower limit is ________. For the upper limit, use the same step:


14−1=13 days,14 days,14+1=15 days.14-1=13\ \text{days},\qquad 14\ \text{days},\qquad 14+1=15\ \text{days}.


The value immediately below the upper limit is ________. Combine the selections and check for duplicates; none occur.


The final suite contains 6 distinct cases: reject 1 day; accept 2, 3, 13, and 14 days; reject 15 days. The endpoints are accepted because the specified range is inclusive.


c) The service rejects 14 days but produces the specified outcome for every other case in part b. How many cases disagree with the specification, and what can you conclude?


Compare each observed response with the expectation established in part b. Five cases match their expected outcomes. The remaining case submits 14 days, which satisfies


2≤14≤14.2\leq14\leq14.


Its expected outcome is acceptance, but its observed outcome is rejection. Therefore, 1 of the 6 cases disagrees with the specification.


You have demonstrated incorrect behaviour at the inclusive upper endpoint. The observation does not establish the internal cause. An incorrect comparison is one possible explanation, but black-box evidence alone does not identify which implementation statement produced the rejection.

A booking service specifies that integer group sizes from 1 through 8 are accepted and other integers are rejected. Its implementation is unavailable. Which approach correctly applies black-box testing to this service?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Each technique or idea below is used when you design tests from a specification without looking at the code. Match each term to the description of what it does or provides.

Match each term
A.

Choosing inputs at, and just beside, the edges of each specified range, where off-by-one faults cluster

B.

Deriving tests from the modes a system can be in and the events that move it between them, including events it should ignore

C.

Using experience of common faults, such as empty strings or missing values, to add inputs that no systematic technique produced

D.

Dividing the input domain into classes the specification says are handled the same way, then testing one representative of each class

E.

Listing combinations of input conditions with the action the specification requires for each combination, then testing each rule

F.

The source of the expected result that an observed output is judged against

Error guessing

Equivalence partitioning

Boundary value analysis

Test oracle

Decision table testing

State transition testing

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

An ordering service receives an integer quantity of boxes. It returns regular for quantities from 1 through 24, bulk for quantities from 25 through 80, and reject for every other integer. Complete the expected-response column using exactly regular, bulk, or reject.

Quantity of boxesExpected response
-2
1
24
25
80
81

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice