Best practices
Good tests come from good habits as much as good tools. These nine practices help you get reliable results with less maintenance.
1. Don’t automate every test case
Section titled “1. Don’t automate every test case”Automation reduces manual testing but doesn’t remove the need for it. Automate the checks that are repetitive, stable and valuable, and keep exploratory and one-off checks manual.
2. Keep tests independent and short
Section titled “2. Keep tests independent and short”- Make each test stand on its own. Dependent tests are hard to understand and can’t run in parallel, because parallel tests start at the same time.
- Keep tests focused. Around 30 steps is easiest to debug and runs fastest. Avoid going beyond 50 to 60 steps, because long tests are hard to maintain and hard to diagnose when they fail.
3. Build tests that survive UI changes
Section titled “3. Build tests that survive UI changes”Early in a product’s life, frequent UI changes and releases can break existing tests on every build. Use stable selectors, reuse common steps through imported test cases, and use Impact Analysis to update a changed selector across many tests at once.
4. Remove flaky tests
Section titled “4. Remove flaky tests”Teams automate to get consistent results. A test that fails unpredictably costs more debugging time than it saves. Fix it or retire it.
5. Finish every test with an assertion
Section titled “5. Finish every test with an assertion”Assertions check that the text or value you expect appears during the run. Ending a test with one reduces false positives and makes results more accurate. See Assertions.
6. Use advanced features to reduce effort
Section titled “6. Use advanced features to reduce effort”Technique matters as much as automation itself. Store variables, application variables, scripts and data-driven tests save execution time and keep tests short.
7. Run tests often
Section titled “7. Run tests often”Run tests as you create them instead of waiting until your whole automation setup is finished. A test suite can run on demand, on a schedule, through the API or from your CI/CD pipeline.
8. Name tests clearly
Section titled “8. Name tests clearly”A good name describes the functionality being tested, so anyone can understand it a year later, including new team members. When some tests in a large set fail, clear names show you which functionality is broken. Also use tags, descriptions and priorities to keep your tests organized.
9. Share ownership of test automation
Section titled “9. Share ownership of test automation”Don’t leave test automation with one engineer. Give several team members access so they understand the setup and can contribute. Use User management to control who can do what.