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

# Show Test Results Next to Test Cases

> Load the test records of each test case into a Nextedy POWERSHEET sheet, so the result, date and test run of its executions appear beneath the test case.

export const LastReviewed = ({date, state}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  const label = state === "reviewed" ? `Last reviewed and confirmed up to date on ${formatted}` : `Last updated on ${formatted}`;
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      {label}
    </p>;
};

This guide adds the execution results of test cases to a sheet.
You relate test records to your test case type in the data model, expand them in the sheet's source, and bind columns to their properties.
For what a test record is and how Powersheet reads it, see [Test Records](/powersheet/concepts/test-records).

## Prerequisites

* A sheet configuration and its data model that you can edit in the configuration editor
* An entity type for your test cases in that data model
* Test runs in the **same project as the sheet**, holding records of those test cases — records of test runs in other projects are not read

<Note>
  **Nothing here is saved from the sheet**

  Test records are read-only.
  The sheet shows them and never writes them, so this setup adds no editable cells and no data to save from the sheet.
</Note>

<Steps>
  <Step title="Relate Test Records to the Test Case Type">
    In the data model, add a relationship between your test case type and `TestRecord` with `storage: TestRecords`.
    No `linkRole` and no `cardinality` are needed, and `TestRecord` does not have to be declared under `domainModelTypes`:

    ```yaml theme={null}
    domainModelTypes:
      TestCase:
        polarionType: testcase

    relationships:
      - from: TestCase
        to: TestRecord
        storage: TestRecords
    ```

    This gives the test case the navigation property `testRecords`, and each record the navigation property `testRun` to the test run that holds it.

    To use other names, set them on the relationship.
    `direct.name` names the navigation on the `from` type and `back.name` the one on the `to` type:

    ```yaml theme={null}
    relationships:
      - from: TestCase
        to: TestRecord
        storage: TestRecords
        direct:
          name: runs
        back:
          name: verifies
    ```

    The rest of this guide uses the default name, `testRecords`.
  </Step>

  <Step title="Expand the Records in the Source">
    In the sheet configuration, expand `testRecords` under the test case, and `testRun` beneath it if you want to show which test run each record belongs to:

    ```yaml theme={null}
    sources:
      - id: test_cases
        model: rtm
        query:
          from: TestCase
        expand:
          - name: testRecords
            expand:
              - name: testRun
    ```

    If your test cases are reached from another type — requirements, for example — put the same `testRecords` entry under the expand that reaches the test case.
  </Step>

  <Step title="Add Columns for the Record">
    Bind columns to the record's properties with the `testRecords` path:

    ```yaml theme={null}
    columns:
      title:
        title: Test Case
        hasFocus: true
      testRecords.result:
        title: Result
      testRecords.executed:
        title: Executed
      testRecords.executedBy:
        title: Executed By
      testRecords.comment:
        title: Comment
      testRecords.testRun:
        title: Test Run
    ```

    The properties a record offers are `result`, `executed`, `executedBy`, `duration` and `comment`.
    See [Data Model Types](/powersheet/reference/data-model/domainmodeltypes#test-record-and-test-run-types) for what each one holds.
  </Step>

  <Step title="Choose How Many Records Each Test Case Shows">
    Without further configuration, each test case shows its **newest record only**.
    To show more of the history, set `query.take` on the `testRecords` expand to the number of records to keep per test case:

    ```yaml theme={null}
        expand:
          - name: testRecords
            query:
              take: 5
            expand:
              - name: testRun
    ```

    Records come newest first, so `take: 5` keeps the five most recent executions of each test case.
    A larger count loads more rows for every test case in the sheet, so keep it to the history your users read.
  </Step>
</Steps>

## Show the Records of One Test Run

To narrow the sheet to a single test run, filter the `testRecords` expand by the record's key to its run, `testRunId`, which holds the test run's ID.
Reading the value from a [URL parameter](/powersheet/guides/sheet-configuration/parametrize-sheet-url) lets one sheet serve any run:

```yaml theme={null}
    expand:
      - name: testRecords
        query:
          where:
            testRunId: "() => context.parameters.testRun"
```

* Opened with `…&testRun=<test run ID>` in the URL, the sheet shows only the records of that run.
* Opened without the parameter, the condition is dropped and each test case shows its newest record, whichever test run holds it.
* Every test case stays in the sheet either way. One that the run holds no record of shows no record rows.

A test run can hold several records of one test case.
Add `take` beside the `where` to see more than the newest of them — the count applies to the records the filter leaves.

To filter by a field of the test run instead of its ID, put the `where` on the `testRun` expand:

```yaml theme={null}
    expand:
      - name: testRecords
        expand:
          - name: testRun
            query:
              where:
                status: finished
```

A test run type that the data model does not declare carries only `id` and `title`.
To filter by another field such as `status`, declare the type and list the field — see [Data Model Types](/powersheet/reference/data-model/domainmodeltypes#test-record-and-test-run-types).

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| A test case shows one record although it was executed several times | Without a count, only the newest record is loaded | Set `query.take` on the `testRecords` expand |
| A test case shows no records | No test run of the sheet's project holds a record of it, or the filter matches none | Check the test run's project and the `where` on the expand |
| The data model is rejected with `cannot have the property` | A declared test record type lists a property outside `result`, `executed`, `executedBy`, `duration`, `comment` | Remove the property; fields of the test run belong on the test run type |
| `query.take` on another expand has no effect | Only a test case's records are kept by number; on any other expand the count is ignored | Remove it, or narrow that expand with `query.where` instead |
| The sheet fails to load with `is not filterable yet` | The `where` on `testRecords` names a record property that cannot be filtered | Filter by `testRunId` or `result`, or by the test run's fields on the `testRun` expand |

## See Also

* [Test Records](/powersheet/concepts/test-records) — what test records are and which of them a sheet loads
* [Expand Clause](/powersheet/reference/query-api/expand-clause#keeping-the-newest-test-records) — `query.take` and `query.where` on an expand
* [Open a Scoped Sheet with URL Parameters](/powersheet/guides/sheet-configuration/parametrize-sheet-url) — reading URL parameters in a sheet configuration
* [Configure Sources](/powersheet/guides/sheet-configuration/configure-sources) — sources, queries and expansion paths

<LastReviewed date="2026-10-06" />


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