> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slai.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing

> Interactively testing a model in the sandbox.

Slai provides two ways to test your models:

1. Unit Tests
2. E2E tests with the test console

## Writing Unit Tests

You can write unit tests for your models in `test.py`. For example, a basic test suite to verify the output of your model might look like this:

```python theme={null}
def test(model):

  example_input = "This model generates text"
  model_response = model(text=example_input)["generated_text"]

  assert(model_response is not None)
  assert(isinstance(model_response, str))
  assert(len(model_response) > 10)
```

You can run your tests by clicking the **Test** button in the sandbox.

![Test button](https://mintcdn.com/slai-docs/x8Ejwqb1sXwT0acS/img/sandbox/testing/test-button.png?fit=max\&auto=format\&n=x8Ejwqb1sXwT0acS\&q=85\&s=1e31c3d0e42a0a4f84b73d8a670aebc0)

### Running E2E Tests

Slai also provides an interactive test client based on the input and output data types you define in the `handler.py` file.

For example, suppose we've defined a single string field as input, and two string fields as output.

```python theme={null}
inputs = {"text": slai.types.String()}

outputs = {"generated_text": slai.types.String(), "sentiment": slai.types.String()}
```

The test console would generate a schema based on the handler fields defined above:

![Schema based on fields](https://mintcdn.com/slai-docs/x8Ejwqb1sXwT0acS/img/sandbox/testing/schema-based-on-fields.png?fit=max\&auto=format\&n=x8Ejwqb1sXwT0acS\&q=85\&s=19aabf54baa50396db939635243a7ce5)

### Running Tests Against Deployed Models

If you've already deployed your model, you can run your test against the live model in the **Request Type** toggle menu.

**Development** runs the test against the current model in the sandbox. **Live** runs the test against the deployed model.

![Live vs. Development](https://mintcdn.com/slai-docs/x8Ejwqb1sXwT0acS/img/sandbox/testing/live-deployment.png?fit=max\&auto=format\&n=x8Ejwqb1sXwT0acS\&q=85\&s=3340af21991b3aee4d038dda546a63a4)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.