You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers software testing strategies for the OCR A-Level Computer Science (H446) specification. Testing ensures that software is correct, reliable, and meets its requirements. You need to understand different testing types, techniques, and tools.
Testing is essential because:
Exam Tip: Know the difference between verification ("Are we building the product right?") and validation ("Are we building the right product?"). Testing contributes to both.
Unit testing tests individual components (functions, methods, or classes) in isolation from the rest of the system.
def add(a: int, b: int) -> int:
return a + b
# Unit tests
assert add(2, 3) == 5
assert add(-1, 1) == 0
assert add(0, 0) == 0
| Advantage | Disadvantage |
|---|---|
| Fast to run | Does not test component interactions |
| Easy to isolate and fix bugs | Many tests needed for full coverage |
| Can be automated | May miss integration-level bugs |
Integration testing tests the interactions between components that have already been unit tested. It verifies that modules work correctly when combined.
| Approach | Description |
|---|---|
| Top-down | High-level modules first; uses stubs for untested lower modules. |
| Bottom-up | Low-level modules first; uses drivers for higher modules. |
| Big bang | All modules integrated at once (risky -- hard to isolate faults). |
System testing tests the complete, integrated system against the original requirements specification. It covers both functional and non-functional requirements.
Acceptance testing is performed by end users or clients to verify the software meets their needs.
| Type | Description |
|---|---|
| Alpha testing | Internal testing within the development organisation. |
| Beta testing | Testing by a limited group of external users before public release. |
Exam Tip: Know the testing order: Unit -> Integration -> System -> Acceptance. Each level tests at a broader scope.
| Category | Description | Example (age field, valid: 0-120) |
|---|---|---|
| Normal (valid) | Data within the expected range | 25, 50, 100 |
| Boundary | Data at the edges of valid ranges | 0, 1, 119, 120 |
| Erroneous (invalid) | Data outside the range or wrong type | -1, 121, "abc", 999 |
For a valid range of 1 to 100:
| Test Value | Category | Expected Result |
|---|---|---|
| 0 | Erroneous (below min) | Rejected |
| 1 | Boundary (minimum) | Accepted |
| 2 | Normal (above min) | Accepted |
| 50 | Normal | Accepted |
| 99 | Normal (below max) | Accepted |
| 100 | Boundary (maximum) | Accepted |
| 101 | Erroneous (above max) | Rejected |
Exam Tip: Always include boundary values in your test plans. Many mark schemes specifically award marks for boundary data at both the minimum and maximum.
TDD is a development approach where tests are written before the code.
# Step 1: Write failing test
def test_is_palindrome():
assert is_palindrome("racecar") == True
assert is_palindrome("hello") == False
assert is_palindrome("") == True
# Step 2: Write minimum code to pass
def is_palindrome(text: str) -> bool:
return text == text[::-1]
# Step 3: Refactor if needed
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.