Skip to content
Course outline: Test design

Module 02 · Test design

Test design methods: black, white and gray box

How much of the inside you can see decides how you design the cases. Here are the methods, and the techniques that go with each.

  • 14 min read
  • Free, no sign-up

What you'll be able to do

  • Tell black-box, white-box and gray-box testing apart, and say who usually does each.
  • Design tests with boundary values, equivalence partitions, a decision table and a state model.
  • Cut a large set of combinations down to all pairs, and turn a use case into tests.
  • Plan an exploratory session with a charter and a time box.

Understanding Testing Methods

Testing methods are approaches used to verify software quality, varying by the tester's knowledge of the application's internal workings. The primary methods—Black Box, White Box, and Gray Box—along with Experience-Based techniques, each serve unique purposes in quality assurance.

Black Box Testing

A software testing method where functionalities are tested without knowledge of internal code structure, implementation details, or internal paths. Focuses on input/output based on requirements and specifications. Also known as Behavioral Testing. Typically performed by the QA team.

How to Perform
  1. Examine requirements and specifications.
  2. Choose valid inputs (positive scenarios) and invalid inputs (negative scenarios).
  3. Determine expected outputs for all chosen inputs.
  4. Construct test cases with selected inputs.
  5. Execute the test cases.
  6. Compare actual outputs with expected outputs.
  7. Report defects, re-test fixes.
Types

Functional Testing

Tests specific functions/features (e.g., login validation). Includes smoke, sanity, integration, system testing.

Non-Functional Testing

Tests 'how' software performs (usability, performance, compatibility, security).

Regression Testing

Checks if new versions introduce defects (regressions) in existing functional or non-functional aspects.

Common Techniques

Boundary Value Analysis (BVA)

Tests values at the boundaries of valid/invalid partitions.

Age range 21-65. Test: 20 (invalid), 21 (valid), 22 (valid), 64 (valid), 65 (valid), 66 (invalid).

Importance:

  • Effective for ranges/numeric inputs.
  • Catches errors at edges.
  • Complements Equivalence Partitioning.

Equivalence Partitioning (EP)

Divides input data into equivalent partitions; tests one value from each.

Age range 6-10 valid. Test: 4 (invalid partition 1), 8 (valid partition), 12 (invalid partition 2).

Importance:

  • Reduces number of test cases.
  • Maintains test coverage.
  • Efficient for large input domains.

Decision Table Testing

Uses tables for combinations of inputs and their outputs, useful for complex business rules.

Login: Rules for combinations of Correct/Incorrect Username/Password leading to HomePage/Error.

Importance:

  • Handles complex conditions.
  • Ensures good coverage for rule-based systems.
  • Easy to interpret.

State Transition Testing

Models how the system moves between different states based on events/inputs.

Graph-Based Testing

Models the application as a graph to identify test paths.

When to Use
  • When internal structure is unknown or irrelevant.
  • Testing from an end-user perspective.
  • Validating software against requirements.
  • System testing, Acceptance testing.
  • Testing large, complex applications where internal details are too vast.

White Box Testing

A testing technique examining the internal structure, design, and coding to verify input-output flow and improve design, usability, and security. Code is visible to testers. Also known as Clear/Open/Transparent/Code-Based/Glass Box Testing. Often performed by developers.

How to Perform
  1. Understand the Source Code: Learn the code, programming languages, and secure coding practices.
  2. Create Test Cases and Execute: Write code to test the source code (unit tests), or use manual testing, trial-and-error, and testing tools.
What to Verify
  • Internal security holes.
  • Broken or poorly structured paths.
  • Flow of specific inputs through the code.
  • Expected output verification.
  • Functionality of conditional loops.
  • Testing of each statement, object, function individually.
Common Techniques

Statement Coverage

Ensures every line of code is executed at least once.

Function Prints(a, b). If a=3, b=9, result > 0, path covers 5/7 statements (71%). If a=-3, b=-9, result < 0, path covers 6/7 statements (85%). Both scenarios together cover 100%.

Decision Coverage

Ensures each boolean expression (decision) evaluates to both TRUE and FALSE.

Function Test(a). If a=7 (a > 4 is TRUE), coverage is 50%. If a=3 (a > 4 is FALSE), coverage is 50%. Both needed for 100%.

Branch Coverage

Ensures every possible branch from each decision point is executed at least once.

if (a > 0 && b > 0): two tests take both branches, one where the decision is true (a = 1, b = 1) and one where it is false (a = -1, b = 1). Trying all four true and false combinations of the two conditions is multiple condition coverage.

Condition Coverage

Ensures each individual condition within a decision evaluates to both TRUE and FALSE.

Multiple Condition Coverage

Tests all possible combinations of outcomes for conditions within each decision.

Path Coverage

Aims to execute every possible path through the code (often impractical).

/ Advantages & Disadvantages

Advantages:

  • Code optimization by finding hidden errors.
  • Test cases can be easily automated.
  • More thorough as all code paths are usually covered.
  • Can start early in SDLC, even without GUI.

Disadvantages:

  • Can be complex and expensive.
  • Developers might perform less detailed testing.
  • Requires resources with deep programming knowledge.
  • Time-consuming for large applications.
When to Use
  • When internal code structure is accessible.
  • Unit testing and component testing.
  • Integration testing (verifying interactions between components).
  • Optimizing code and improving performance.
  • Security testing to find vulnerabilities in the code.
  • Early in the SDLC.

Gray Box Testing

A software testing technique using partial knowledge of the internal structure (e.g., architecture, database schema, logs) combined with black-box techniques. Aims to identify defects due to improper code structure or application use.

Common Techniques

Matrix Testing

Analyzes variable usage within a program to identify unused or uninitialized variables.

Program uses `total_price`, `discount`, `tax`, `final_price`. `unused_variable` is identified and recommended for removal.

Regression Testing

Verifies that code changes (e.g., bug fixes) haven't negatively impacted other parts of the software.

Fixing a 'Transfer Funds' fee bug. Regression tests check if 'Bill Pay' or 'Account Balance' display are now broken.

Orthogonal Array Testing (OAT)

Uses orthogonal arrays to test pair-wise combinations of parameters with a minimal number of test cases.

Printer Driver (Size, Orientation, Color). OAT reduces 12 combinations to 6 test cases covering all pairs.

Pattern Testing

Leverages knowledge of past defects in similar software/patterns to design tests targeting likely problem areas.

Previous e-commerce sites had session issues. New site testing focuses heavily on session persistence and interruptions.

Fault Injection Testing

Deliberately introduces errors (e.g., invalid data, network failures) to test system robustness and error handling.

Simulate network failure during financial transaction; check if system handles error gracefully and rolls back.

Data Flow Testing

Focuses on variable life cycles (definition, usage, modification) to find improper data use.

Track item price from cart addition to final payment; verify calculations are correct at each step.

API Testing

Tests APIs using partial knowledge of their structure for functionality, reliability, performance, security.

Send valid/invalid requests to weather API; check response format, error handling, performance.

Memory Leak Testing

Identifies if the application fails to release memory, potentially causing performance issues or crashes.

Run photo editor continuously, monitor memory usage with profiling tools to find leaks.

Back-End Testing

Tests server-side components and databases using knowledge of schemas/queries.

Verify creating/updating a user correctly modifies the database and enforces constraints.

Configuration Testing

Checks application behavior across different hardware/software configurations.

Test mobile app on various devices, OS versions, screen sizes, and system settings.
Generic Steps
  1. Select inputs using both BlackBox & WhiteBox perspectives.
  2. Identify expected outputs for these inputs.
  3. Identify major paths to traverse during testing.
  4. Identify sub-functions for deep-level testing.
  5. Identify inputs for sub-functions.
  6. Identify expected outputs for sub-functions.
  7. Execute test cases for sub-functions.
  8. Verify the correctness of results.
/ Advantages & Disadvantages

Advantages:

  • Combines benefits of black-box and white-box.
  • More comprehensive than black-box alone.
  • Less time-consuming than full white-box.
  • Better vulnerability detection based on partial knowledge.
  • Tests from user perspective with some internal insight.
  • Unbiased approach, avoids tester/developer conflicts.
  • Effective for integration testing.

Disadvantages:

  • Limited code access means some implementation bugs might be missed.
  • Requires some technical knowledge.
  • Test case design can be complex.
  • Not as thorough as full white-box.
  • Defect association can be difficult in distributed systems.
  • Not suitable for algorithm testing.

Experience-Based Testing

Relies on the tester's skill, intuition, and past experience. Often used ad-hoc when specifications are inadequate or unavailable. Testers focus on areas likely to fail or be heavily used.

Types

Error Guessing

Uses tester's experience/intuition to anticipate likely problematic areas or common errors.

Testing scenarios like divide by zero, blank inputs, submitting empty forms, uploading oversized files.

Importance:

  • Effective with other techniques.
  • Finds bugs missed by formal methods.
  • Supplements formal design.
  • Good for guessing problem areas.

Checklist-Based Testing

Uses a pre-planned list of tasks or checks, often created by experienced testers.

Image Upload Checklist: Check path, different extensions (JPEG, BMP), same names, size limits, progress bar, cancel button, multiple uploads, quality.

Importance:

  • Easy to read and execute.
  • Quick status tracking.
  • Flexible ordering.
  • Good source for reports.

Exploratory Testing

Simultaneous learning, test design, and execution. Testers explore the system 'on the fly' without pre-defined cases. Focuses on 'thinking' and discovery. Widely used in Agile.

Like driving in a new region without a map, using intuition and standard strategies (ask directions, look for signs) to reach the destination.

Importance:

  • Useful with poor requirements.
  • Finds more bugs through investigation.
  • Uncovers bugs missed by other techniques.
  • Improves tester creativity/productivity.
  • Drills down into application details.

Attack Testing

Simulates potential attacks to find security vulnerabilities. Relies on knowledge of common attack vectors.

Attempting to reset another user's password by manipulating URLs or guessing security questions.

Importance:

  • Enhances security posture.
  • Prevents financial/reputational damage.
  • Improves software quality & user trust.
  • Helps meet compliance standards.
  • Promotes proactive risk management.
When to Use
  • Requirements/specifications are unavailable or inadequate.
  • Limited knowledge of the software product initially.
  • Time constraints prevent a fully structured approach.
  • To complement specification-based and structure-based techniques.
  • Suitable for low-risk systems.

Worked examples on Cedar Books

Seven techniques applied to Cedar Books, the Academy's practice shop, each to the part of the shop it suits best. Each example links the tool that draws the same table, and the lab where you run the tests on the real shop.

Worked example · Cedar Books

Boundary values: copies, free delivery and stars

Three Cedar Books requirements set ranges with clear edges. Two-value boundary value analysis tests each edge and its nearest neighbour outside the range:

Boundary values from three Cedar Books requirements
RequirementValid rangeValues to testExpected
REQ-05: copies of one book1 to 100, 1, 10, 111 and 10 accepted; 0 and 11 refused
REQ-09: free delivery30.00 or more is free29.99 and 30.00Delivery 3.50 at 29.99; free at 30.00
REQ-11: a review's stars1 to 50, 1, 5, 61 and 5 saved; 0 and 6 refused

Three-value analysis adds the value just inside each edge: 2 and 9 for the copies, 30.01 for delivery, 2 and 4 for the stars. Why the edges? A developer who writes < where the requirement means <= moves a boundary by one, and only a test at the edge notices. Which of these the shop gets wrong is for you to find in the boundary values lab.

Try it: Boundary value analysis tool · The boundary values lab

Worked example · Cedar Books

Equivalence partitions for the copies and the coupon code

Two inputs of the basket, the number of copies (REQ-05) and the coupon code (REQ-03, REQ-06), each split into classes that the shop should treat the same way:

The classes of two basket inputs
InputValid classesInvalid classes
Copies1 to 10 (for example 3)Below 1 (0); above 10 (11); not a number (two)
Coupon codeNo code; a valid code (CEDAR10)Expired (EXPIRED24); used up (SPRING25); unknown (HELLO10)

The rule: cover every valid class with as few tests as possible, and give each invalid class a test of its own, with every other input valid. Two valid tests (3 copies with no code; 3 copies with CEDAR10) and six invalid ones make eight. One invalid input per test matters: a test with 0 copies and an expired code together gets one message, which can explain only one of the two faults; the other goes untested.

Try it: Equivalence partitioning tool

Worked example · Cedar Books

A decision table for the welcome code

WELCOME5 takes 5.00 off a basket of 25.00 or more, once per account. Three conditions decide what happens; with two values each they make 2 x 2 x 2 = 8 rules. Where a condition makes no difference, rules merge (a dash means "either"):

The merged decision table of WELCOME5
RuleCode is validBasket is 25.00 or moreUsed before by this shopperAction
R1YYYRefuse: already used
R2YYNTake 5.00 off
R3YN-Refuse: the basket is under 25.00
R4N--Refuse: the code is not valid

Four tests instead of eight, and no case missed. Writing the table also raises a question the requirement does not answer: what does "used before" mean for a guest, who has no account? Asked before testing starts, a question like that is the cheapest bug a team ever fixes.

Try it: Decision table tool

Worked example · Cedar Books

State transitions of an order

An order at Cedar Books moves between four states: Basket, Checkout, Confirmed, and Waiting for the bank (REQ-07: a slow bank shows a message after 10 seconds). Six moves connect them:

  • Basket, go to checkout: Checkout.
  • Checkout, back to the basket: Basket.
  • Checkout, pay with a card that is approved: Confirmed.
  • Checkout, pay with a card that is declined: Checkout again, with an error and no order.
  • Checkout, pay while the bank is slow: Waiting for the bank.
  • Waiting for the bank, the bank approves: Confirmed.

State transition testing first covers every valid move at least once: six tests. Then it tries the moves that must not happen: four states times six events make 24 cells, and 18 of them are invalid moves, such as paying again from Confirmed. A second round, the 1-switch cases, tests pairs of moves in a row, such as a declined card followed by an approved one.

Try it: State transition tool · The journey lab

Worked example · Cedar Books

Pairwise tests for the checkout

Checkout depends on five settings: the browser (Chrome, Firefox, Safari, Edge), the device (desktop, phone, tablet), the test card (approved, declined, slow bank), the coupon (none, CEDAR10, WELCOME5) and the shopper (guest, signed in). Every combination is 4 x 3 x 3 x 3 x 2 = 216 checkouts.

Most faults caused by settings need only two of them to meet: Safari with a declined card, a phone with a coupon. Pairwise testing makes sure every pair of values meets in at least one test, and 14 checkouts cover all 88 pairs. One pair is left out on purpose: a guest with WELCOME5. The code is "once per account" and the requirement does not say what a guest gets, so that case goes to the product owner as a question, and is tested on its own once it is answered.

The orthogonal array testing in this lesson is the same idea built from a fixed mathematical table; all-pairs tools build the list by search instead. The pairwise tool draws all 14 rows.

Try it: Pairwise testing tool · The regression suite lab

Worked example · Cedar Books

A use case: buying as a guest

A use case describes how an actor reaches a goal with the system: the main flow, step by step, and the alternative flows where something goes differently. Use case testing turns it into tests: one for the main flow, and one for each alternative flow.

Use case: buy a book as a guest
Actor: a shopper who is not signed in
Precondition: the book is in stock

Main flow
1. The shopper finds the book and adds it to the basket.
2. The shopper opens the basket and goes to checkout.
3. The shopper fills in the delivery address and pays
   with the approved test card.
4. The shop shows "Order confirmed" and an order number.
5. The shop's mailbox holds a confirmation with the
   order number and the total paid (REQ-08).

Alternative flows
2a. A coupon is applied first: the total paid is lower.
3a. The card is declined: an error, and no order (REQ-07).
3b. The bank is slow: a message after 10 seconds,
    never a blank page (REQ-07).
3c. An address field is empty: the shop asks for it.

Postcondition: one order exists, and the basket is empty.

Five tests come out of it: the main flow and the four alternatives. Each runs from the first step to its own end, so each checks its own end state: one order and an empty basket, or no order at all.

Try it: The journey lab

Worked example · Cedar Books

An exploratory charter for the coupon field

Exploratory testing is not random. A session starts from a charter, a short mission, and runs for a fixed time. A common form is: explore a target, with certain resources, to discover certain information.

Charter: explore the coupon field in the basket
  with unusual codes (lower case, spaces, two codes
  in a row, an expired code, a code applied before
  a book is removed)
  to discover whether each code is treated the way
  REQ-03 and REQ-06 say.
Time box: 45 minutes. Notes as you go.

During the session the tester writes down what was tried (the coverage), what looked wrong (bugs, with steps and evidence) and what was unclear (questions for the product owner). At the end, a short debrief with the test lead decides what becomes a bug report, what deserves a scripted test, and what the next charter should be.

Try it: The exploratory session lab · Bug report builder

Methods Comparison

AspectBlack BoxWhite BoxGray Box
Knowledge of CodeNo knowledgeComplete knowledgePartial knowledge
FocusFunctionality, UICode paths, structureArchitecture, data flow
Performed ByQA, End-usersDevelopers, Skilled QAQA/Dev with partial insight
AdvantagesUser perspective, SimplerThorough coverage, Early detectionCombines benefits, More efficient than white
DisadvantagesLimited insight, Can miss logic errorsTime-consuming, Needs coding skillsNot full code view, Can be complex
Typical Use CaseAcceptance, System TestingUnit, Integration TestingIntegration, API Testing

Sign in to keep your progress: a tick here lives in this browser only.

Test yourself

Quiz: Test design methods

10 questions, about 8 minutes. Sign in to take the quiz.

Sign inRequest accessStart freeGet started

10 questions, about 8 minutes, no time limit. 7 right answers pass, and passing marks the lesson as read. Every new quiz draws new questions.

Put the lessons to work on a real site

Describe a user journey in plain English. QAIA walks it in a real browser and hands back the test cases, the automation code and the evidence of every step.