# Running and Tracking Tests

A **test run** is a recorded execution of one or more test cases. SpeQA stores each run as a `.tr.md` file and opens it in an interactive run editor where you record a verdict for every step. A single run can cover several test cases at once.

## Three Ways to Start a Run

### From a single test case (Run button)

1. Open a `.tc.md` test case file.
2. In the editor header, click the green **Run** (play) button. Its tooltip reads **Start a manual test run**.
   - You can also right-click a `.tc.md` file in the project or the SpeQA tool window and choose **Run Test Case**.
3. The **Create test run** dialog opens. Choose what to import from the source case (see [Import options](#import-options)), then review the suggested session folder and file name before clicking **Create**.

The default destination is a new timestamped session folder under the configured run destination. The file name defaults to the source case's `.tc.md` file stem with the `.tr.md` extension. This produces a run with a single test case section.

### From the TRs tab

1. Open the **SpeQA** tool window and switch to the **TRs** tab.
2. Click the **+** action in the tab's title bar, use **Create test run** in the empty state, or right-click a TRs folder and choose **New test run in this folder…**.
3. The **Create test run** dialog lists all test cases in the project. Every listed case starts checked; use the filters, **Select all**, or **Clear** to adjust the selection.
4. Set the run title, destination, and file name, then click **Create**. When you use **New test run in this folder…**, the clicked folder is the base destination for a new session folder. If you invoke it on a session folder, the new session is created beside it, not inside it.

The new run contains one case section for each selected test case.

### From a test-case folder

In the **TCs** tab, right-click a folder and choose **Create test run from this folder…**. The dialog lists the cases in that folder and its subfolders, with every listed case checked. Adjust the selection if needed, review the run destination and file name, then click **Create**. The folder supplies the cases; it does not set the destination.

After a run is created, SpeQA opens it in the run editor, activates the **TRs** tab, and selects the new run there, leaving the keyboard focus in the editor so you can start recording verdicts right away.

## Session Folders and Run Names

Each run creation creates one session folder named with the local creation time in `yyyy-MM-dd_HH-mm` form. If another session already uses that minute in the same destination, SpeQA appends `-2`, `-3`, and so on to the folder name. A run from one case uses the case file stem as its default filename; a run from multiple cases uses the active filter label as a lowercase kebab-case filename, or `test-run.tr.md` when there is no single active label. If a filename already exists inside the session folder, a numeric suffix is added before `.tr.md`.

For example, a smoke session can contain one file per case:

```text
test-runs/smoke/
└── 2026-10-21_14-09/
    ├── free-plan-default-credit-limit-grant.tr.md
    └── another-smoke-case.tr.md
```

The default run title starts with the creation time, for example `2026-10-21 14:09 - TC-129 Default credit limit`; you can edit it in the dialog. Canceling the dialog does not create an empty session folder. Existing runs stay where they are; the new layout applies to runs created after this change.

## Import Options

The Create test run dialog lets you choose which source-case data to copy. All options are **off by default**. **Tags** and **Environment** are collected from the selected cases, deduplicated, and stored once on the new run. Description, tickets, links, and attachments stay with their corresponding case or step:

- **Description** - the case's description and preconditions
- **Tags**
- **Environment**
- **Tickets** - ticket references on steps
- **Links**
- **Attachments**

An option is disabled when the source case has nothing of that kind to import.

## The Run Editor

The run editor header shows the run **ID** and title, overall **Result**, **Progress**, **Runner**, **Environment**, and **Tags**. Each case owns its **Priority**, description, links, attachments, preconditions, and steps. In a multi-case run, these fields appear inside that case's collapsible section; a single-case run shows the same case fields in the flat preview. Zero or one case uses the flat preview, while two or more cases use sections. The preview switches layouts automatically after a Markdown edit adds or removes case sections, without reopening the file.

### Recording step verdicts

Every step has four verdict buttons:

- **Passed**
- **Failed**
- **Skipped**
- **Blocked**

Click a verdict to set it. Click the currently selected verdict again to clear it back to *not set*. Each step also has a comment button (the balloon icon) for recording an observation - especially useful on failed or blocked steps.

### Per-case result

Each case section header shows a **result pill**. It is normally derived automatically from that case's step verdicts, but you can click it to override the result manually (Passed, Failed, Blocked, In progress, Not started), or choose **Auto (from steps)** to go back to the derived value. A small indicator marks a result that was set manually.

### Overall run result

The header **Result** is a dropdown showing the aggregate of the per-case results. Picking a value pins a manual override for the whole run (Passed, Failed, or Blocked); picking **Not started** clears the override and returns to the automatic aggregate. While overridden, a manual indicator appears next to the dropdown. The aggregate is computed as follows:

- All steps unset -> **Not started**
- Some steps have a verdict, some do not -> **In progress**
- All steps have a verdict (Skipped ignored for the final result): any **Failed** -> **Failed**; otherwise any **Blocked** -> **Blocked**; otherwise -> **Passed**

### Managing cases in the run

For a run that covers several cases, the header offers:

- **Expand all cases** / **Collapse all cases** to open or close every case section at once. Sections start collapsed for fast loading.
- A drag handle on each section header so you can reorder the cases.

A **Reset results** button (next to the Result control) clears every step verdict and every case/run result back to *not started* after a confirmation. Step text, comments, and metadata are preserved. It is disabled when the run is already untouched.

### The `.tr.md` format

Run-level fields such as tags and environment are stored in the YAML frontmatter. Each `Test Case:` section contains that case's priority, description, links, attachments, preconditions, steps, and results. For example, `checkout.tc.md` created at 17:07 in the default `test-runs` destination is stored as `test-runs/2026-04-11_17-07/checkout.tr.md`:

```markdown
---
id: 42
title: "2026-04-11 17:07 - TC-12 Checkout"
result: in_progress
runner: "QA"
tags:
  - "smoke"
environment:
  - "staging"
---

Test Case: TC-12 Checkout
priority: major

Description of this case.

Links:

[Checkout issue](https://tracker.example.com/ISSUE-12)

Preconditions:

A customer account exists.

Scenario:

1. Submit an order
   > The confirmation page appears
   - Passed
```

## Run History

Each run is its own `.tr.md` file inside the session folder created for that run. Running the same test case again creates a new session folder and file, so the set of `.tr.md` files under your test-runs folder is the execution history. Open any run file directly to review its recorded verdicts and comments; you can edit them after the fact.

Browse runs in the **TRs** tab of the [SpeQA tool window](/speqa/tool-window/index.md), where you can filter them by result, priority, tags, and environment.

## Attachments and Evidence

Links and attachments belong to a specific case or step, not to the run as a whole. Add a screenshot or log file to the relevant case section or step to document what you observed. See [Test Case Properties](/speqa/test-case-properties/index.md) for how attachments and links work.

## Troubleshooting

**The Run button does nothing / no run is created:**
- Make sure you completed the Create test run dialog and clicked **Create** (an invalid destination keeps the button disabled).
- Confirm the destination folder is inside the project.

**The TRs "+" / Create test run button is disabled:**
- A run needs at least one test case. Create a test case first.

**Can't find my run file:**
- Runs are saved in a timestamped session folder under the destination you chose in the dialog (under `test-runs` by default).
- Look in the **TRs** tab of the SpeQA tool window - the newly created run is selected there.

## What's Next?

- Organize and filter runs in the [SpeQA tool window](/speqa/tool-window/index.md)
- Learn about [Test Case Properties](/speqa/test-case-properties/index.md) to enrich your evidence
- Set up the [Test Case Writer skill](/speqa/claude-code-skills/index.md) to write cases faster
