TEST.run

Runs another test.

Use this to reuse snippets in different tests.

Note:

All tests are ran in the same scope. This means that variables with the same name in different tests will override each other.

Usage

TEST.run(path)
Parameter Type Remarks
path string Path to the test to run.

# Basic example

Say we have a test named "login" here that we want to use in other tests:

// Contents of "login" test script
I.goTo("/login");
I.fill("username", "john");
I.fill("password", "supersecretpassword");
I.click("Login");

We can run "login" in a another test using the TEST.run command like this:

I.goTo('http://mystore.com');

// Run the "login" test
TEST.run("login"); 

// Then do other stuff
I.click("Profile")
I.fill("Change password", "superlongpassword");
I.click("Save");

And the actual script that will be executed is this:

I.goTo('http://mystore.com');

// Start: "login" test script
I.goTo("/login");
I.fill("username", "john");
I.fill("password", "supersecretpassword");
I.click("Login");
// End: "login" test script

I.click("Profile")
I.fill("Change password", "superlongpassword");
I.click("Save");

# Using relative paths

We can specify tests to run relative to the current test file using ./ to refer to the current directory and ../ to refer to the parent directory.

Let's take this project with this structure for example.

|-- login
|-- order
   |-- create_and_view_order
   |-- create_order
   |-- view_order

From the order/create_and_view_order test, we can run other tests using relative paths like this:

TEST.run("../login") // use "../" to reference the parent directory
TEST.run("./create_order") // use "./" to referece the current directory
TEST.run("./view_order")