2.12 Testing
2.12.1 Testing components
Why Test Individual Components?
Components should be tested individually before final integration to
identify issues early and reduce complexity.
Components include:
Components include:
- Software
- Hardware
- Data
- Interfaces
- Resulting service (final product)
2.12.2 Testing methods
Testing Methods: Purpose, Benefits, Drawbacks
- Concept: Validates ideas early (low cost, limited detail)
- Unit: Tests individual functions (fast, isolated)
- Boundary: Tests edge values (finds limit errors)
- Integration: Tests combined components (complex setup)
- Performance: Measures speed/resource usage
- System: Tests the full solution end‑to‑end
- Acceptance: Confirms requirements met
- Usability: Tests user interaction
- Regression: Ensures changes don’t break features
- Load/Stress: Tests under heavy demand
- Closed box: No code knowledge
- Open box: Code‑aware testing
Using Testing Methods (Python Examples)
Unit test example:
def add(a, b):
return a + b
assert add(2, 3) == 5
Boundary test example:
def validate_age(age):
return 0 <= age <= 120
assert validate_age(0)
assert not validate_age(121)
2.12.3 Automation
Automated Testing Methods
Automation reduces manual effort and increases consistency.
Methods include:
Methods include:
- Macros – automate repetitive actions
- Scripts – automated test execution
- Functional testing tools
for i in range(5):
print("Running test", i + 1)
2.12.4 Test data and test plans
Types of Test Data
Test data is used to verify correctness.
- Valid: Expected to pass
- Invalid: Expected to fail
- Boundary: Edge values
- Erroneous: Incorrect type/format
test_values = [50, -1, 100, "abc"]
for value in test_values:
print(value)
Test Plan Structure
A test plan defines how testing will be carried out.
It includes:
It includes:
- Tests to be carried out
- Purpose of each test
- Test data used
- Expected results
- Actual results