Best Practices

Here we wanted to talk about the best practices to help you create tests that succeed for the first time.
To avoid false positives, please try to implement these best practices

Before you start recording

When you record your tests, make sure you start and end the tests in a clean state:

• Make sure you are in a clean-state

For example if the user's cart is not empty make sure it is.

• Log out

When you're recording your tests, it helps to think from a new user's perspective so that when we run your tests on the cloud, there will be no errors associated with your local state.

Start with a login test

If you have a web app that requires logging in, your first test should be the Login test.

After the login test is created you can re-utilize that test. So you don't have to log in each time you want to record a new test.

After tests are recorded, they are going to be run in the cloud. Which means they won't be in the same state your browser has.

Keep your tests small

Keeping your tests as small as possible can help you determine what failed pretty easily.

Our recommended size is around 30 steps.

Don't record the same step in different tests

Doing so will make it harder to fix the tests if there is an error. For example, if you have multiple tests that require you to log in first and if logging in doesn't work you have to go through each test to fix the problem. For this we recommend using Workflows. Workflows allow you to re-utilize tests so that if there is a problem with a single proponent such as login you would only need to fix it once.

Create tests that can run simultaneously

Be sure that tests don't interact with each other's data in order to run simultaneously.

For example, if two tests manipulate the same data table at the same time, the tests will most likely break.

Running your tests simultaneously will make it so you can get results faster.

Don't use test users that are in automated tests

Using the same login credentials as Login on Preflight for your own local tests may cause data to become corrupt and potentially break the tests. You should always have a different account for your local testing and a different account for Preflight.

Updated at Thu, Jan 20, 2022