Best Practices
To avoid false positives, and increase your tests' success rate, it is recommended to implement the following best practices.
Before Recording
Before you record a test:
- Ensure you start and end the tests in a clean state The browser's state should reflect a user's experience when using your web app. For example if the user's cart has items in it, ensure you empty it before you start recording.
- Log out
- Clean your cookies
Create a Login Test
If you have a web app that requires logging in, your first test should be a Login test.
After creating the login test, you can re-utilize that test to prevent you from logging in each time you need to record a new test. See Creating your first loging test for more information.
Keep Your Tests Small
Keeping your tests as small as possible will enable you to quickly locate problems in the event that the test fails.
Don't Record the Same Step in Different Tests
Recording the same step in different tests makes it harder to fix tests if there is an error. For example, if you have multiple tests that require you to log in first, and the log in doesn't work, you will need to go through each test to fix the problem. To prevent this it is recommended to use Workflows, which enable you to re-utilize tests so that if there is a problem with a single component you will only need to fix it once.
Create Tests That Can Run Simultaneously
Ensure that your tests don't interact with each others' data to enable them to run simultaneously, and receive faster results.
For example, if two tests manipulate the same data table at the same time, the tests are likely to fail.
Don't Use Test Users That Are in Automated Tests
Using the same login credentials in your Login test on Preflight for your own local tests may cause data to become corrupt and potentially break the tests. Ensure you have a different account for your local tests.
Related topics