Reusable tests

In the previous chapter, we created a test to verify our authentication flow works.

Since Magic Inspector does not persist any state between tests, it's very likely that we'll want to run this test as part of multiple flows.

To do so, we can transform our test into a reusable test.

Reusable tests are a way to define a test once and reuse it across multiple flows.

Creating a reusable test

Once you've created a test, you can make it reusable by clicking on the Make it reusable button.

Made as reusable test

There are a few things to keep in mind when creating reusable tests:

  • The start URL of a reusable test won't be used anymore since it will be replaced by the current URL of the flow that uses the test.
  • You can use multiple reusable tests into a single test, however you cannot have a reusable test inside another reusable test.
  • If a test uses a reusable test, you will be billed for one run and not two since the reusable test will be executed as part of the parent test.

Using a reusable test

Let's create a new test - in this example we named it "Parent test" (1) - and add our reusable test into it.

To use a reusable test inside another test, you just have to create an instruction of type Import Reusable Test (3) and choose the reusable test you want to use (3).

Importing a reusable test

Running the test

You can run the test as you would run any other test. Magic Inspector will import the reusable test and all the instructions inside it.

Running a test with a reusable test

Congratulations! You've just created your first reusable test.

What's next?

You've now learned the basics of how to create and use reusable tests.

In the next chapter, we'll learn how to schedule tests to run on a regular basis and get notified when they fail.

Was this page helpful?