> For the complete documentation index, see [llms.txt](https://docs.testery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testery.io/get-to-know-testery/test-runs/test-selection-rules.md).

# Test Selection Rules

The Test Selection feature enables your team to run a subset of the tests based on changes made to the source files.

In order to start using this feature, your repository should have a `testery.yml` file defined. This file should include a section as described below.

When running tests from the UI, be sure to select the "Use testery.yml" option.

<figure><img src="/files/yAG22oB5lebJOjtNVi1f" alt=""><figcaption></figcaption></figure>

### testery.yml syntax for defining test selection rules

```
test_selection:
  suites:
    - default:
      rules:
        - employeeRule:
          when:
            - src_changes:
                - "src/employees/*"
          then:
            - include_tags:
                - "employees"
                - "smoke"   
        - itemRule:
          when:
            - src_changes:
                - "src/items/*"
          then:
            - include_tags:
                - "items"
```

Currently, Testery supports 1 suite of rules, named "default". Within the suite, you'll need a list of "rules". Each rule has a "when" and a "then".

#### When Conditions

When conditions are used to trigger a set of tests to be selected.

* **src\_changes** - This trigger will apply a glob expression to the list of files changed in the code branch.

#### Then Conditions

Then conditions refine the tests that will be selected

* **include\_tags**: If your testing framework supports tags, then this can be used to specify the tags that will be included in the test run
* **exclude\_tags:** If your testing framework supports tags, then this can be used to specify the tags that will be excluded in the test run
* **test\_filters:** A glob expression that can be applied to choose the tests to run


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.testery.io/get-to-know-testery/test-runs/test-selection-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
