# 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](/testrunner/testrunnerconsole.md) 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.”

<figure><img src="/files/miabHruMaCCLUc2BuBaX" alt="Test Project Add"><figcaption></figcaption></figure>

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

<figure><img src="/files/Yl6HNB0oapds9R0lNjF6" alt="Type of Tests"><figcaption></figcaption></figure>

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.

<figure><img src="/files/Iyidnmc7SzenuXshWEJt" alt="Run Tests"><figcaption></figcaption></figure>

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

<figure><img src="/files/UbvzEOeIhkTURlwVINCS" alt="Test Explorer With Error"><figcaption></figcaption></figure>

***

## Start and Stop a Service

Use the [StartService](/reference/plugins/linx/content/startservice.md) and [StopService](/reference/plugins/linx/content/stopservice.md) 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.linx.software/testrunner/testrunner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
