Always write tests as if the person who ends up maintaining them will be a violent psychopath who knows where you live.
Test maintenance is essential for keeping the test suite relevant, accurate, and effective in detecting issues and ensuring the overall quality of the software throughout its lifecycle.
Test Characteristics
Ideally, every individual test would exhibit the follwing qualities:
-
The test scenario is not complicated: one can understand it in less than 3 minutes without a need to execute it (applies both to manual scripts and automated tests).
- The test does not contain unrelated instructions, implicit dependencies, sequential coupling, or other tricky content
- Test data is isolated from the test scripts and self-descriptive.
- The test context is obvious and can be changed without impacting the test objectives
Test Suite Characteristics
The following characteristics are generally applicable to creating a maintainable test suite:
- The tests are traced to the test basis: requirement, user story or the other source of information the test is derived from.
- The tests are grouped by functional areas, test types, and other criteria as needed.
- There are no duplications in test scenarios and instructions.
- The tests are stored in version control systems (e.g., Git) to allow easy tracking of changes and rollbacks if necessary.
- The test suite is periodically reviewed and refactored to help keep tests relevant and maintainable. Duplicate or unnecessary tests are eliminated.
Test Automation Services Characteristics
The test automation system is another is another big part of the test ecosystem which should be maintainable to allow effective support and regressions.
- The test automation services should be designed following the clean code principles, with a dedicated architecture targeting the test automation system needs.
- Test Automation Services include appropriate error handling and reporting mechanisms. Clear and informative error messages help identify issues quickly and aid in troubleshooting.
- Test Automation Services includes unit tests (validation tests) which allow the validation of the test services themself.
- The tests include labels to allow the execution of a subgroup by specified criteria.
- A smoke subset of automated tests is run regularly to expose possible issues in the automation services or changes in the software under test.
Other Maintenance Tips
- Stick to The Millers’ number (7±2) in any deliverable you create: number of lines in a single test, number of tests in a test file, number of test files in a test category, number of test data samples in a directory, etc. Don’t create supercontainers (neither files nor directories): they are not maintainable.
- Maintenance does not assume extension: whatever reason urges you to update the existing test with new scenario steps or verification checks: just don't do it. Create a new test instead.
- In test automation, test maintainability is more critical than framework maintainability. Even a poorly designed test automation framework would be easier to refactor than a huge number of badly written tests.