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.
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
- Examine requirements and specifications.
- Choose valid inputs (positive scenarios) and invalid inputs (negative scenarios).
- Determine expected outputs for all chosen inputs.
- Construct test cases with selected inputs.
- Execute the test cases.
- Compare actual outputs with expected outputs.
- 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.
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.
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.
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
- Understand the Source Code: Learn the code, programming languages, and secure coding practices.
- 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.
Decision Coverage
Ensures each boolean expression (decision) evaluates to both TRUE and FALSE.
Branch Coverage
Ensures every possible branch from each decision point is executed at least once.
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.
Regression Testing
Verifies that code changes (e.g., bug fixes) haven't negatively impacted other parts of the software.
Orthogonal Array Testing (OAT)
Uses orthogonal arrays to test pair-wise combinations of parameters with a minimal number of test cases.
Pattern Testing
Leverages knowledge of past defects in similar software/patterns to design tests targeting likely problem areas.
Fault Injection Testing
Deliberately introduces errors (e.g., invalid data, network failures) to test system robustness and error handling.
Data Flow Testing
Focuses on variable life cycles (definition, usage, modification) to find improper data use.
API Testing
Tests APIs using partial knowledge of their structure for functionality, reliability, performance, security.
Memory Leak Testing
Identifies if the application fails to release memory, potentially causing performance issues or crashes.
Back-End Testing
Tests server-side components and databases using knowledge of schemas/queries.
Configuration Testing
Checks application behavior across different hardware/software configurations.
Generic Steps
- Select inputs using both BlackBox & WhiteBox perspectives.
- Identify expected outputs for these inputs.
- Identify major paths to traverse during testing.
- Identify sub-functions for deep-level testing.
- Identify inputs for sub-functions.
- Identify expected outputs for sub-functions.
- Execute test cases for sub-functions.
- 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.
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.
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.
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.
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:
| Requirement | Valid range | Values to test | Expected |
|---|---|---|---|
| REQ-05: copies of one book | 1 to 10 | 0, 1, 10, 11 | 1 and 10 accepted; 0 and 11 refused |
| REQ-09: free delivery | 30.00 or more is free | 29.99 and 30.00 | Delivery 3.50 at 29.99; free at 30.00 |
| REQ-11: a review's stars | 1 to 5 | 0, 1, 5, 6 | 1 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:
| Input | Valid classes | Invalid classes |
|---|---|---|
| Copies | 1 to 10 (for example 3) | Below 1 (0); above 10 (11); not a number (two) |
| Coupon code | No 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"):
| Rule | Code is valid | Basket is 25.00 or more | Used before by this shopper | Action |
|---|---|---|---|---|
| R1 | Y | Y | Y | Refuse: already used |
| R2 | Y | Y | N | Take 5.00 off |
| R3 | Y | N | - | Refuse: the basket is under 25.00 |
| R4 | N | - | - | 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.
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.
Methods Comparison
| Aspect | Black Box | White Box | Gray Box |
|---|---|---|---|
| Knowledge of Code | No knowledge | Complete knowledge | Partial knowledge |
| Focus | Functionality, UI | Code paths, structure | Architecture, data flow |
| Performed By | QA, End-users | Developers, Skilled QA | QA/Dev with partial insight |
| Advantages | User perspective, Simpler | Thorough coverage, Early detection | Combines benefits, More efficient than white |
| Disadvantages | Limited insight, Can miss logic errors | Time-consuming, Needs coding skills | Not full code view, Can be complex |
| Typical Use Case | Acceptance, System Testing | Unit, Integration Testing | Integration, 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.
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.