Design tips to minimize maintenance
Easy maintenance is no random accident. The tips below help ensure you have the right tests through the lifetime of your application.
Decide what to test before you decide how to test it.
Document your test cases.
Documentation can help ensure that each test case has been well-designed with preconditions for the test, steps to execute, and expected results. It can be very helpful to use a test case template or a tool such as TestRail to organize your test case documentation.
Keep it simple.
Use naming standards.
Comments that address why a test is as it is are an exception, that is, such comments are beneficial. “Product management set a requirement that this operation must complete within three seconds” is an example of a good comment in relating a test to a decision made outside the tests. “Calculate the result” is almost certainly a bad comment, because at best it communicates something better expressed in the test itself.
Coding tips to minimize maintenance
Specific stylistic choices make maintenance easier, whether a particular test is fully automated or not.
Use a modular structure.
At the same time, certain actions are likely to appear in many distinct cases — a successful login, for example. Part of modularization is the definition of useful common initializations or setups which multiple otherwise-separate tests share.
Design automated tests to be immune to UI changes.
Group tests by functional area.
Don't copy-and-paste test code.
Separate test steps from test data.
Use source control.
The workflows for application source code almost certainly apply equally well to test source code. Does your programming team review updates to the source? Does the source conform to definite stylistic rules? The source code for tests deserves the same standards: don’t just capture tests in a source control system, but practice code review and automated validation to help ensure the quality of tests under source control.
Manage Your Source Code Securely
Hosted and on-prem solutions for Git, SVN and Perforce
Execution tips to minimize maintenance
The best tests don’t just require little maintenance in a general sense, but they share specific execution-time characteristics: their results are reproducible, and their resources demands for time, memory, and disk space are predictable.
Take advantage of modern virtualization techniques. Test on “clean” hosts, whether newly-launched virtual machines or fresh container images or otherwise known safe starting points. This kind of computing hygiene minimizes contamination of test results by external confusions or accidents.
Ensure that your test environment is stable.
Use setup and teardown processes.
Fail fast.
Fail only when necessary.
Isolate expected failures.
Take screenshots.
All-in-one Test Automation
Cross-Technology | Cross-Device | Cross-Platform