Executes a program with artificial data to check for errors, anomalies, or non-functional issues. Dynamic V&V.
Testing reveals the presence of errors, not their absence. Certain errors may be masked by other errors.
Goals
Validation Testing
Demonstrates that the system meets its requirements. A successful test shows the system works as intended.
Defect Testing
Discovers situations where the system behaves incorrectly. A successful test exposes a defect by making the system fail.
Automated Testing
Testing performed without manual intervention. Implemented through a testing framework such as JUnit or Vitest.
Parts of an automated test:
- Setup
Initialize the system with inputs and expected outputs. - Call
Invoke the methods or functions under test. - Assertion
Compare expected and actual output. Pass if equal, fail otherwise.
Regression Testing
Re-runs all tests after changes to ensure previously working behavior is preserved. Most practical when automated.
Performance and Stress Testing
Performance testing gradually increases load until the system degrades. Stress testing deliberately overloads the system to observe failure behavior.
Partition Testing
Inputs are grouped into equivalence partitions (sets of inputs the program treats identically). Test cases are selected from each partition. 1 representative per partition is sufficient.
Guideline-Based Testing
Uses experience of common programmer errors to select test cases.
Stages of Testing
Development Testing
Done by the development team.
- Unit testing
Test individual components in isolation. Automate where possible. Inheritance makes unit testing of classes more difficult. - Component testing
Test interfaces between integrated units. - System testing
Test the whole integrated system.
Release Testing
Done by a separate team. Validates the system before it reaches users. Checks functionality, performance, and dependability.
User Testing
Involves actual users.
- Alpha testing
Conducted at the developer’s site. - Beta testing
Released to a subset of real users. - Acceptance testing
Customer decides if the system is deployable.
Test-Driven Development
Tests are written before the code. Tests serve as the specification up front and as the regression suite thereafter.
TDD cycle:
- Identify a small increment of functionality.
- Write an automated test that initially fails.
- Implement code to pass the test.
- Re-run all tests. Refactor if needed.
- Move to the next increment.
Benefits:
- Code coverage
Every code segment has at least one test. - Regression testing
The incremental test suite prevents regressions. - Simplified debugging
A failing test points directly to the new code. - Documentation
Tests describe what the code should do.