SE Notes
Testing based on requirements without knowledge of internal code.
Black-box testing (also called specification-based or functional testing) designs test cases based entirely on the software's requirements and specifications without any knowledge of the internal code structure. The tester treats the system as an opaque box—inputs go in, outputs come out, and the tester verifies that outputs match expected behavior based on requirements. This approach is powerful because it tests what the system should do (from the user's perspective) rather than what the code actually does (which may itself be wrong).
Why Black-Box Testing Matters
If testers design tests based on reading the code, they may unconsciously follow the same logic the programmer used—and share the same blind spots. A programmer who misunderstood the requirement might implement incorrect logic that looks reasonable in code. A tester reading that code might write tests that verify the (incorrect) implementation rather than the (correct) requirement. Black-box testing avoids this trap by deriving tests directly from specifications.
Additionally, black-box testing is accessible to non-technical testers—domain experts, business analysts, and end users can design meaningful test cases from requirements without programming knowledge.
Key Black-Box Techniques
Equivalence Partitioning
This technique divides input data into partitions (classes) where all values in a partition should be treated identically by the system. Instead of testing every possible value, you test one representative value from each partition.
Example: A function accepts age (integer, 1-150) and returns insurance category:
- Ages 1-17: "Minor" (one partition)
- Ages 18-25: "Young Adult" (one partition)
- Ages 26-64: "Adult" (one partition)
- Ages 65-150: "Senior" (one partition)
- Ages < 1 or > 150: "Invalid" (invalid partitions)
Test cases: Test one value from each partition (e.g., 10, 20, 40, 70, -1, 200). If the system handles 20 correctly, it should handle all values 18-25 correctly because they belong to the same equivalence class.
Boundary Value Analysis
Defects cluster at the boundaries between equivalence partitions. This technique tests values at, just below, and just above each boundary:
Decision Table Testing
When the system's behavior depends on combinations of conditions, a decision table systematically covers all combinations:
Example: Shipping cost depends on order total and membership status:
| Condition | Rule 1 | Rule 2 | Rule 3 | Rule 4 |
|---|---|---|---|---|
| Order > $100 | Yes | Yes | No | No |
| Premium Member | Yes | No | Yes | No |
| Action | ||||
| Free Shipping | ✓ | ✓ | ||
| Standard Rate | ✓ | |||
| Higher Rate | ✓ |
Each column becomes a test case, ensuring every combination of conditions is tested.
State Transition Testing
Tests based on the valid and invalid transitions between system states:
Example: User account states: Active → Locked (after 3 failed logins) → Active (after password reset)
Test valid transitions: Active user enters wrong password 3 times → account becomes Locked. Test invalid transitions: Locked account attempts login → remains Locked (should not revert to Active without reset).
Real-World Example: Flight Booking Validation
Testing the passenger count field on a flight booking form:
Equivalence Partitions:
- Valid: 1-9 passengers (economy booking limit)
- Invalid low: 0 or negative numbers
- Invalid high: 10 or more passengers (requires group booking)
- Invalid type: non-numeric input ("abc", special characters)
Boundary Values: 0, 1, 9, 10 Decision Table: Combine with one-way/return, domestic/international, peak/off-peak
Test cases:
- Book for 1 passenger (minimum valid) → Success
- Book for 9 passengers (maximum valid) → Success
- Book for 0 passengers → Error: "At least 1 passenger required"
- Book for 10 passengers → Redirect to group booking
- Enter "abc" as passenger count → Error: "Please enter a number"
- Book for 5 passengers, return trip, international, peak → Verify correct pricing applied
Advantages of Black-Box Testing
Tests are derived from user perspective (validates actual requirements), testers do not need programming knowledge, tests remain valid even when code is refactored (requirements unchanged), and it catches defects that white-box testing misses (missing functionality that was never coded cannot be found by examining code).
Limitations
Cannot ensure complete code coverage (unreachable code or dead code is never tested), may miss defects in error handling paths not specified in requirements, and cannot test internal efficiency or code quality. Black-box testing should be complemented by white-box testing for comprehensive quality assurance.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Black Box Testing.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Software Engineering topic.
Search Terms
software-engineering, software engineering, software, engineering, testing, black, box, black box testing
Related Software Engineering Topics