How To Use Test Runner

The Test Runner brings nUnit style functionality to Linx, making regression testing of a Linx solution easier.

The Test Runner console can also be used to run these tests.


Test Project

The test runner will execute tests created in a Test Project. To add a Test Project, right-click on the Solution and select “Add Test Project.”

Test Project Add

Tests are added to a Test Project by adding functions and setting their type. Functions added to a Test Project have the following types:

  • Function – a standard Linx function ignored by the test runner

  • One-time setup – runs once before tests run

  • One-time teardown – runs once after tests finish

  • Setup – runs before every test

  • Teardown – runs after every test

  • Test – a test

Type of Tests

Test, setup, teardown, one-time setup, and one-time teardown functions can be added anywhere in a Test Project. The Test Runner executes test functions in the following order:

  1. Execute one-time setup functions in parent folders starting from the project root and working down.

  2. For each folder:

    1. Execute one-time setup functions

    2. For each test function:

      • Execute setup functions

      • Execute the test function

      • Execute teardown functions

      • For each sub-folder, repeat 2

    3. Execute one-time teardown functions

  3. Execute one-time teardown functions in parent folders, starting with the parent and working up.

Multiple setup or one-time setup functions in the same folder execute alphabetically.

Multiple teardown or one-time teardown functions in the same folder execute in reverse alphabetical order.

If any setup or one-time setup function fails, the test run for the folder stops.

Multiple tests in the same folder may run in any order.


Executing tests

To run tests, right-click on any test function or folder that contains tests and select "Run Tests". If you select a folder or the Test Project, all the tests it contains, including those in subfolders, will run.

Run Tests

See the results of tests in the Test Explorer. Here you can also see the error if a test failed.

Test Explorer With Error

Start and Stop a Service

Use the StartService and StopService functions to start or stop a Linx service. Services are typically started in setup functions and stopped in teardown functions.

Setup and Teardown Data

Setup and teardown functions can pass data to downstream setup, teardown, or test functions. To emit data, add a result to the emitting function. To consume the value, add a parameter with the same name and type to the consuming function.

Last updated