# Tests object schema

dbt platform | Starter, Enterprise, Enterprise+

[Tests](../build/data-tests.md) are assertions you make about your models and other resources in your dbt project. When you run `dbt test`, dbt will tell you if each test in your project passes or fails. You can query tests through the Discovery API to understand information about them.

The [Example query](#example-query) illustrates a few fields you can query with the `tests` object and how to filter by last-known result. Refer to [Fields](#fields) to view the entire schema, which provides all possible fields you can query.

### Arguments

When querying for `tests`, you can use the following arguments:

# Fetching data...

Deprecation: `lastKnownResult`

The single-value filter field `lastKnownResult: TestStatus` is deprecated. You should now use `lastKnownResults: [TestStatus]` to filter tests by one or more result statuses. If you pass both fields in the same query, `lastKnownResults` takes precedence. Refer to [Filter tests by last-known result](#filter-tests-by-last-known-result) for more information.

### Filter tests by last-known result

You can filter tests by one or more last-known result values. Use `lastKnownResults` with any combination of these `TestStatus` values:

* `pass`
* `fail`
* `error`
* `skipped`
* `warn`

You can still use the deprecated `lastKnownResult`, but If you pass both fields in the same query, `lastKnownResults` takes precedence.

An empty list `[]`, omitting `lastKnownResults`, or passing `null` applies no filter on last-known result. All tests are returned regardless of result status.

### Example query

You can return tests whose last-known result is `error` or `fail`:

```graphql
query {
  environment(id: 834) {
    applied {
      tests(
        filter: {
          lastKnownResults: [error, fail]
        },
        first: 100
      ) {
        edges {
          node {
            name
            model
            description
            expect
            resourceType
            testType
            given
            lastKnownResult
          }
        }
      }
    }
  }
}
```

You can combine `lastKnownResults` with other filters on `TestAppliedFilter`, such as `testTypes`:

```graphql
query {
  environment(id: 834) {
    applied {
      tests(
        filter: {
          testTypes: [GENERIC_DATA_TEST, SINGULAR_DATA_TEST],
          lastKnownResults: [fail]
        },
        first: 100
      ) {
        edges {
          node {
            name
            model
            description
            expect
            resourceType
            testType
            given
            lastKnownResult
          }
        }
      }
    }
  }
}
```

### Fields

When querying for `tests`, you can use the following fields:

# Fetching data...

### Key fields from nodes

# Fetching data...

## Was this page helpful?

YesNo

[Privacy policy](https://www.getdbt.com/cloud/privacy-policy)[Create a GitHub issue](https://github.com/dbt-labs/docs.getdbt.com/issues)

This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.
