# Supported Framework

Gathering coverage and test information using the SeaLights Python agent is done in a few steps:

{% hint style="info" %}
See '[Generating an Agent token](https://docs.sealights.io/knowledgebase/settings/token-access-and-management#token-list-and-token-creation-2)' for instructions on how to generate a token
{% endhint %}

{% hint style="warning" %}
**Test Duration Requirements for Coverage Calculation**\
Please note that tests must run for at least 1 second for SeaLights to calculate coverage. If your test duration is under 1 second, adding a brief pause will allow SeaLights to complete the coverage sampling process.
{% endhint %}

## Running your tests - Functional Tests <a href="#running-your-tests-functional-tests" id="running-your-tests-functional-tests"></a>

Before running your functional tests you need to set up the backend server to receive the test footprints. See [running-backend-server-using-sealights-agent](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/capturing-coverage-from-runtime-application/running-backend-server-using-sealights-agent "mention").

Once set up you now run your tests with one of the following flags

## Running tests with unittest <a href="#running-tests-with-unittest" id="running-tests-with-unittest"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python unittest --teststage "Unit Tests" {--cov-report /path/to/report.xml} <your args...>
```

{% endcode %}

## Running tests with pytest <a href="#running-tests-with-pytest" id="running-tests-with-pytest"></a>

{% hint style="danger" %}
Sealights agent conflicts with the `pytest` coverage option (`--cov`), and this option must be removed when using the `sl-python` command below.
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python pytest <Options ...> <pytest args...>

Options:
--tokenfile                            <Text>                     A path to a file where the program can find the token. Case-sensitive
--token                                <Text>                     Token (mandatory. Can also be provided by 'tokenfile' argument). Case-sensitive
--labid                                <Text>                     Lab Id, case-sensitive
--buildsessionidfile                   <Text>                     (Deprecated) Path to a file to save the build session id in. Use --labid instead.
--buildsessionid                       <Text>                     (Deprecated) Provide build session id manually. Use --labid instead.
--teststage                            <Text>                     {E.g: integration tests, regression, [Unit Tests]}
--cov-report                           <Path>                     {E.g: /path/to/report.xml}
--per-test                             <StrToBool>                {E.g: false, [true]}
--interval                             <Integer in milli second>  {E.g: 20000, [10000], 5000}
-tsd, --test-selection-disable         <Flag> 
-tsri, --test-selection-retry-interval <Integer in second>        {E.g: 1, [5], 10}
-tsrt, --test-selection-retry-timeout  <Integer in second>        {E.g: 30, [60], 120} 
```

{% endcode %}

{% hint style="warning" %}
If the `pytest-cov` module exists in your project with an older version than defined in the `sl-python` dependencies, coverage collection will fail.\
This can be avoided by removing `pytest-cov` from your dependencies, as `sl-python` will install this automatically.
{% endhint %}

## Running tests with unittest2 <a href="#running-tests-with-unittest2" id="running-tests-with-unittest2"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python unit2 --teststage "Unit Tests" {--cov-report /path/to/report.xml} <your args...>
```

{% endcode %}

## Running tests with nose <a href="#running-tests-with-nose" id="running-tests-with-nose"></a>

{% hint style="danger" %}
Sealights agent conflicts with `nose` coverage options (`-with-coverage --cover-package=server` for example), and they must be removed when capturing coverage via the `sl-python` command below
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python nose --teststage "Unit Tests" {--cov-report /path/to/report.xml} <your args...>
```

{% endcode %}

## Running tests with behave <a href="#running-tests-with-behave" id="running-tests-with-behave"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python behave --tokenfile sltoken.txt --teststage "Functional Tests" --labid my_app_env <your args...> 
```

{% endcode %}
