A tester and a developer look at the same checkout bug. The tester says, "I typed an 11-character code and it was accepted. The spec says 10 is the max." The developer opens the function and says, "The max-length check is off by one, and none of our unit tests ever made it fire." Both are right. They just tested from different sides of the box.
That is the whole debate in one bug. One person tested what the feature should do. The other tested how the code does it. You need both, and the useful question is which one to use where.
Updated December 2026
Black box vs white box testing comes down to what the tester can see. Black box testing checks behavior against the requirements without looking at the code. White box testing designs tests from the code itself, aiming for statement, branch, condition or path coverage. Black box finds missing or wrong features. White box finds untested logic.
Key takeaways
- Black box testing uses the spec. White box testing uses the source code. Grey box uses partial knowledge, such as the API contract or database schema.
- The core black box techniques are equivalence partitioning, boundary value analysis, decision tables, state transitions and use cases. The core white box techniques are statement, branch, condition and path coverage.
- This guide runs every technique on one feature, a discount-code field, so you can see the actual partitions, table rows, code and test cases.
- Use white box at the unit level and black box at the system and acceptance levels. Most teams need both, because each one misses what the other catches.
What is the difference between black box and white box testing?
The ISTQB Foundation syllabus puts it cleanly. Black-box techniques are "based on an analysis of the specified behavior of the test object without reference to its internal structure." White-box techniques are based on the test object's "internal structure and processing" (ISTQB CTFL v4.0.1, section 4.1).
Two consequences follow from that definition, and they matter more than any list of pros and cons:
- Black box tests survive refactoring. If the code changes but the required behavior doesn't, the tests still apply.
- White box tests can only be written after the code exists. They depend on the design, so they change when the design changes.
The same syllabus adds a third family, experience-based techniques (error guessing, exploratory testing, checklists), which complement both. If you want the bigger map, our guide to types of software testing places all three in context.
Most top-ranking articles on black box vs white box testing stop at definitions and a list of technique names. Below, every technique is applied to the same feature, with real values, so you can copy the pattern into your own test cases.
The example feature: a discount-code field
Here is the spec we'll test. It's small, but it has ranges, rules, states and a flow, which is all you need to show every technique.
| Rule | Spec |
|---|---|
| R1. Format | A code is 6 to 10 characters, letters and digits only. Codes are not case sensitive. |
| R2. Validity | The code must exist and must not be expired. |
| R3. Minimum order | The cart subtotal must be at least $20.00. |
| R4. Discount | Each code gives between 10% and 50% off, set by an admin. Members get 5 extra points, capped at 50%. |
| R5. Lockout | After 3 failed attempts in a session, the field locks for 15 minutes. |
| R6. One code | Only one code can be applied per order. |
Which black box testing techniques should you use?
Black box testing works from rules R1 to R6 alone. You never open the code.
Equivalence partitioning
Split each input into groups the system should treat the same way, then test one value per group. If one value in a partition passes, the theory says the rest will too.
| Input | Partition | Valid? | Test value |
|---|---|---|---|
| Code length | 0 characters (empty) | Invalid | "" |
| Code length | 1 to 5 characters | Invalid | SAVE |
| Code length | 6 to 10 characters | Valid | SAVE20 |
| Code length | 11 or more characters | Invalid | SAVE20EXTRA |
| Characters | Letters and digits only | Valid | SAVE20 |
| Characters | Contains a symbol or space | Invalid | SAVE-20 |
| Case | Lowercase version of a real code | Valid | save20 |
| Subtotal | Below $20.00 | Invalid | $12.00 |
| Subtotal | $20.00 or more | Valid | $64.00 |
| Code status | Exists and active | Valid | SAVE20 |
| Code status | Does not exist | Invalid | NOSUCH1 |
| Code status | Expired | Invalid | SUMMER24 |
Twelve tests cover twelve partitions. Notice the invalid rows. Those are your negative tests, and they're where most real defects in input fields live.
Boundary value analysis
Defects cluster at the edges of partitions, where someone typed < instead of <=. ISTQB describes two versions (section 4.2.2). 2-value BVA tests each boundary and its nearest neighbor in the next partition. 3-value BVA tests the boundary and both neighbors, which catches more off-by-one bugs.
Here is 3-value BVA for our field:
| Boundary | Values to test | Expected result |
|---|---|---|
| Minimum length (6) | 5, 6, 7 characters | Reject, accept, accept |
| Maximum length (10) | 9, 10, 11 characters | Accept, accept, reject |
| Minimum subtotal ($20.00) | $19.99, $20.00, $20.01 | Reject, accept, accept |
| Minimum discount (10%) | 9%, 10%, 11% (admin screen) | Reject, save, save |
| Maximum discount (50%) | 49%, 50%, 51% (admin screen) | Save, save, reject |
| Member cap (50%) | Member with a 44%, 45%, 46% code | 49%, 50%, 50% off |
The member-cap row is easy to miss. It isn't an input field at all. It's a boundary inside a calculation, and you only find it by reading R4 carefully.
Decision table testing
When the outcome depends on a combination of conditions, list the combinations. A dash means "doesn't matter for this rule."
| Condition / action | Rule 1 | Rule 2 | Rule 3 | Rule 4 | Rule 5 |
|---|---|---|---|---|---|
| Format valid (R1) | N | Y | Y | Y | Y |
| Code exists (R2) | – | N | Y | Y | Y |
| Code not expired (R2) | – | – | N | Y | Y |
| Subtotal ≥ $20.00 (R3) | – | – | – | N | Y |
| Message | "Codes are 6 to 10 letters or digits" | "Code not recognized" | "This code has expired" | "Add $X more to use this code" | Discount applied |
| Counts as failed attempt? | No | Yes | Yes | No | No |
Five rules, five test cases. The last row is where the table pays off. Writing it forces a question the spec didn't answer: does a badly formatted code count toward the lockout? Take that question to the product owner before you write a single test.
State transition testing
The lockout rule (R5) makes the field a small state machine.
| Current state | Event | Next state | Visible result |
|---|---|---|---|
| S0: Ready, 0 failures | Valid code | Applied | New total shown |
| S0: Ready, 0 failures | Invalid code | S1: 1 failure | Error message |
| S1: 1 failure | Invalid code | S2: 2 failures | Error message |
| S1: 1 failure | Valid code | Applied | New total, counter resets |
| S2: 2 failures | Invalid code | Locked | "Try again in 15 minutes" |
| Locked | Any code | Locked | Field disabled |
| Locked | 15 minutes pass | S0: Ready | Field enabled |
| Applied | Remove code | S0: Ready | Original total shown |
| Applied | Second code | Applied | "Only one code per order" (R6) |
Testing each row once gives you what ISTQB calls 0-switch coverage, every valid transition exercised at least once. The "Locked + any code" and "Applied + second code" rows are the invalid transitions, the ones users trigger by accident and developers forget to block.
Use case testing
Use cases test the flow end to end, with a main path and alternates. (ISTQB moved use case testing out of the v4 Foundation syllabus into the Advanced Test Analyst one, but it's still widely used for system tests.)
Main flow: Shopper adds $64 of items, enters SAVE20, clicks Apply, sees $51.20, pays $51.20.
Alternate flows:
- Shopper enters an expired code, sees the expiry message, enters a valid one, and the discount applies.
- Shopper applies
SAVE20on a $25 cart, then removes an item so the subtotal drops to $15. The discount should be removed with a message, not silently kept. - Shopper applies a code, refreshes the page, and the discount is still there.
Alternate flow 2 is the one that ships as a bug. No input-level technique finds it, because every individual input was valid. If you want a format for writing these up, see how to write test cases in manual testing.
How do white box testing techniques work on the same feature?
Now open the box. Here is a simplified version of the code behind the field. The decisions are labeled D1 to D5.
def apply_discount(code, subtotal, codes, attempts, is_member):
if attempts >= 3: # D1
return "locked"
if len(code) < 6 or len(code) > 10 or not code.isalnum(): # D2
return "bad_format"
promo = codes.get(code.upper())
if promo is None or promo.expired: # D3
return "invalid"
if subtotal < 20: # D4
return "below_minimum"
percent = promo.percent
if is_member: # D5
percent = min(percent + 5, 50)
return round(subtotal * (100 - percent) / 100, 2)
Assume codes holds SAVE20 (20%, active) and SUMMER24 (15%, expired).
Statement coverage
Every executable line runs at least once. Five tests do it:
| Test | Inputs | Result | New lines covered |
|---|---|---|---|
| T1 | attempts = 3 | "locked" | D1 return |
| T2 | code = SAVE | "bad_format" | D2 return |
| T3 | code = NOSUCH1 | "invalid" | lookup, D3 return |
| T4 | SAVE20, subtotal = 15 | "below_minimum" | D4 return |
| T5 | SAVE20, subtotal = 100, member | 75.0 | percent, D5 body, final return |
That's 100% statement coverage. It still leaves a gap. No test runs D5 as false, so a bug that only hits non-members goes unseen. ISTQB makes the same point: 100% statement coverage "does not ensure that all the decision logic has been tested" (section 4.3.1).
Branch coverage
Every decision takes both its true and false outcome. Add one test:
| Test | Inputs | Result | New branch covered |
|---|---|---|---|
| T6 | SAVE20, subtotal = 100, not a member | 80.0 | D5 false |
Six tests, 100% branch coverage. Branch coverage always includes statement coverage, but not the reverse.
Condition coverage
Branch coverage treats D2 as one yes-or-no question. It's really three conditions joined by or. T2 makes D2 true using only the first one (len < 6). So the checks for len > 10 and not isalnum() have never been true. If the developer had written len(code) > 11, every test so far would still pass. That's the bug from the opening.
Condition coverage makes each atomic condition true and false at least once:
| Test | Inputs | Condition made true | Result |
|---|---|---|---|
| T7 | SAVE20EXTRA (11 characters) | len(code) > 10 | "bad_format" |
| T8 | SAVE-20 | not code.isalnum() | "bad_format" |
| T9 | SUMMER24 | promo.expired (D3) | "invalid" |
Note that T7 and T8 match values from the black box partitions above. The two methods meet in the middle. Stricter variants exist, such as modified condition/decision coverage (MC/DC), where each condition must be shown to change the outcome on its own.
Path testing
A path is one complete route from entry to exit. This function has no loops, so the paths are easy to count:
| Path | Route | Test |
|---|---|---|
| P1 | D1 true | T1 |
| P2 | D1 false, D2 true | T2 |
| P3 | D1, D2 false, D3 true | T3 |
| P4 | D1 to D3 false, D4 true | T4 |
| P5 | D1 to D4 false, D5 true | T5 |
| P6 | D1 to D4 false, D5 false | T6 |
Six paths, which matches the cyclomatic complexity: five decisions plus one. Path testing adds little here because the early returns keep paths separate. It earns its place in code with loops and decisions that don't return, where the number of paths grows much faster than the number of branches.
| Coverage level | Tests needed here | What it still misses |
|---|---|---|
| Statement | 5 (T1–T5) | D5 false; untested conditions in D2 and D3 |
| Branch | 6 (T1–T6) | len > 10, symbols, expired codes |
| Condition | 9 (T1–T9) | Data-dependent bugs, such as rounding on $0.01 carts |
| Path | 6 here, many more with loops | Anything not in the code, such as R6 or alternate flow 2 |
That last cell is the key limit of white box testing. Code coverage only measures the code that exists. The missing "remove discount when subtotal drops" logic has no line to cover.
What is grey box testing?
Grey box testing sits between the two. The tester knows some internals, such as the API contract, database schema or architecture, but still tests through the public interface.
For our field, a grey box tester who has read the schema and API spec might add:
- Case handling. The code is stored uppercase and the lookup calls
upper(). So testsave20,Save20and a code with a Turkish dotted I, where uppercasing behaves differently. - Lockout scope. The attempts counter is stored per session, not per account. Opening a new browser session resets it, which is a brute-force risk worth reporting.
- API bypass. Send
POST /cart/discountdirectly with a 50-character code to check the server repeats the length check the UI already enforces.
It is common in integration testing, API testing and security testing, where knowing the contract tells you which inputs are worth sending.
Black box vs white box testing: how do they compare side by side?
| Black box | White box | Grey box | |
|---|---|---|---|
| Tests against | Requirements and spec | Source code and design | Spec plus partial internals |
| Knowledge needed | Domain and requirements, no code | Programming, the codebase | API contracts, schemas, architecture |
| Usually done by | QA engineers, business analysts, end users | Developers, SDETs | QA engineers, SDETs, security testers |
| Main levels | System, acceptance, end-to-end | Unit, component | Integration, API, security |
| Techniques | Partitioning, BVA, decision tables, state transition, use cases | Statement, branch, condition, path coverage | Black box techniques guided by known internals |
| Coverage measured as | Requirements or rules covered | Statements, branches or conditions executed | Both, informally |
| Example tools | Selenium, Playwright, API clients | coverage.py, JaCoCo, Istanbul | API clients, database queries, proxies |
| When tests can be written | As soon as the spec exists | After the code exists | After the interfaces are defined |
| Survives refactoring | Yes, if behavior is unchanged | Often needs updates | Mostly |
| Finds best | Missing features, wrong behavior, usability issues | Dead code, untested branches, logic errors | Integration faults, data issues, security gaps |
| Misses | Hidden logic paths, untested code | Missing requirements, wrong spec | Deep code paths, full user journeys |
| Main cost | Can't see what wasn't tested inside | Needs coding skill, breaks on redesign | Needs access to internals and docs |
A few tool notes from the vendors' own docs. coverage.py measures statement coverage and adds branch coverage with the --branch flag. JaCoCo reports instruction, branch, line, method and class counters plus cyclomatic complexity. Selenium WebDriver drives Chrome, Firefox, Edge and Safari. Playwright drives Chromium, Firefox and WebKit from TypeScript, Python, .NET or Java.
When should you use black box vs white box testing?
Use this as a starting decision table for your own test levels:
| Situation | Start with | Why |
|---|---|---|
| Writing unit tests for new business logic | White box (branch coverage) | You own the code and can see every decision |
| Testing a feature against its acceptance criteria | Black box (partitions, BVA, decision tables) | The criteria are the spec |
| Rules with many combined conditions (pricing, eligibility) | Black box decision tables, then white box condition coverage | Tables find missing rules, conditions find untested logic |
| Workflows with steps and statuses (orders, approvals, logins) | Black box state transition and use cases | Bugs hide in the transitions, not single inputs |
| Testing APIs and service contracts | Grey box | The contract tells you which inputs matter |
| Testing a third-party or vendor app you can't see inside | Black box | It's your only option |
| Regression suite that must survive refactors | Black box at the UI and API level | Tests don't depend on implementation |
| Safety-critical or security-sensitive code | Both, with stricter condition coverage | Each misses defects the other catches |
In practice, black box vs white box testing splits by role. Developers own white box testing in unit tests and track coverage in CI. QA owns black box testing at the system level. The weak spot is the middle, where nobody owns the alternate flows. That's where a functional testing plan earns its keep.
Where does Robonito fit?
In black box vs white box testing terms, Robonito is a black box tool, and we'd rather say so plainly.
Robonito is an agentic QA platform. Its AI agents create, run and maintain end-to-end tests from the outside, through the UI and the API. In AI Studio you describe what to test, paste a URL or reference a Jira issue, and the agent works through the app step by step. It can also generate tests from requirement documents, Jira stories, Swagger/OpenAPI definitions and the live app. That suits the black box techniques above. You can describe the decision table rows or the alternate flows in plain language and get runnable tests.
For API-level and grey box style checks, you can import Postman collections. API testing is on the Pro and Enterprise plans, while web testing is on every plan, including Free. Steps self-heal when labels, layouts or locators change, and healed steps are logged for review, which helps black box suites survive UI redesigns.
Where it doesn't fit: Robonito doesn't measure code coverage. It won't tell you that D5 was never false or that a condition in D2 never fired. Keep your unit tests and a coverage tool such as coverage.py or JaCoCo for that. It also isn't a test management tool. It integrates with TestRail and Zephyr for that.
See how it handles end-to-end suites on the automation testing tool page, or compare options in our API test automation tools guide.
·
Frequently asked questions
Is black box testing the same as functional testing?
No, but they overlap. Black box testing describes how you design tests (from the spec, without the code). Functional testing describes what you test (features and behavior). Most functional tests are black box, but non-functional tests such as performance and usability checks can be black box too.
Is unit testing white box or black box?
Usually white box, because developers write unit tests while looking at the code and measure branch coverage. But you can design unit tests from a function's documented contract alone, which is black box testing at the unit level.
Which is better, black box or white box testing?
Neither. The black box vs white box testing question is about fit, not ranking. White box testing finds untested logic in code that exists. Black box testing finds behavior that's missing or wrong, including code nobody wrote. The worked example above shows each one catching a defect the other missed.
Does 100% code coverage mean the software is fully tested?
No. 100% statement coverage can still miss whole branches, and 100% branch coverage can miss individual conditions. Even full path coverage can't detect missing requirements, because there's no code to cover.
Can black box testing be automated?
Yes. Browser tools such as Selenium and Playwright, API clients and agentic platforms all run black box tests. The techniques in this guide (partitions, boundaries, tables) decide what to test. Automation decides how often it runs.
Is penetration testing black box or white box?
It can be either. In black box penetration testing the tester starts with no inside knowledge, like an outside attacker. White box penetration testing gives the tester source code and architecture. Grey box, with credentials and API docs, is a common middle ground.
What is the main difference between grey box and white box testing?
A grey box tester knows some internals but still tests through the public interface. A white box tester designs tests directly from the code and measures which lines and branches ran.
Want black box tests for your UI and API without writing locators? or .




