---
title: tb test
meta:
    description: Run and update tests for your Tinybird project
---

# tb test

Runs and updates tests for your Tinybird project.

The following subcommands are available:

{% table %}
  * Command
  * Description
  ---
  * run [FILES]
  * Runs all the tests in the project or specific tests passed as arguments.
  ---
  * update [FILES]
  * Updates the test's expectations.
{% /table %}

## Create test files

Create test YAML files manually in the `tests/` folder.

For the test file format, see [Test files](/forward/dev-reference/datafiles/test-files).

Example `tests/user_actions.yaml`:

```yaml
- name: user_actions_clicked
  description: Returns clicked actions only
  expected_http_status: 200
  parameters: action=CLICKED
  expected_result: |
    {"action":"CLICKED"}
```

Use `tb test update` to refresh expected results after changing a query.

## tb test run

Runs all the tests in the project `tb test run` or specific tests passed as arguments. Tests are run with fixture data against your local.

For example: `tb test run tests/get_lego_sets_by_year.yaml` will return:

```bash
Running against Tinybird Local

» Building test environment
✓ Done!

» Running tests
* get_sets_by_theme_year.yaml
✓ get_sets_by_theme_year_2000s_range passed
✓ get_sets_by_theme_year_1990s_range passed
```

{% callout type="tip" %}
Tinybird creates a fresh workspace for each test run. Secrets will not persist between test runs. To avoid test failures, add a default value to your secrets: `{{ tb_secret("secret_name", "default_value") }}`.
{% /callout %}

## tb test update

Updates the test's expectations. For example: `tb test update get_lego_sets_by_year`.

## Environment support

{% table %}
  * Environment
  * Supported
  * Description
  ---
  * `--local`
  * ✓ Yes (default)
  * Runs tests locally with fixture data.
  ---
  * `--cloud`
  * ✗ No
  * Tests run locally, not in cloud.
  ---
  * `--branch=BRANCH_NAME`
  * ✗ No
  * Tests run locally, not in branches.
{% /table %}
