Skip to content

Commit 333b229

Browse files
committed
Describe filtering by test type
1 parent 53241a7 commit 333b229

4 files changed

Lines changed: 85 additions & 9 deletions

File tree

docs/cli-reference.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
llms_description: "CLI commands and flags: testo run, --config, --teamcity, --suite, --path, --filter, filter combination logic, exit codes"
2+
llms_description: "CLI commands and flags: testo run, --config, --teamcity, --suite, --path, --filter, --type, filter combination logic, exit codes"
33
---
44

55
# Command Line Interface
@@ -71,7 +71,7 @@ Testo provides three types of filters that can be combined to selectively run te
7171
**Filter Combination Logic:**
7272
- Same type filters use OR logic: `--filter=test1 --filter=test2` → test1 OR test2
7373
- Different type filters use AND logic: `--filter=test1 --suite=Unit` → test1 AND Unit
74-
- Formula: `AND(OR(filters), OR(paths), OR(suites))`
74+
- Formula: `AND(OR(filters), OR(paths), OR(suites), type)`
7575

7676
For detailed information about filtering behavior, see [Filtering](/docs/filtering).
7777

@@ -150,6 +150,35 @@ testo run --filter=UserTest --path="tests/Unit"
150150

151151
**Filter Behavior:** See [Filtering](/docs/filtering) for details.
152152

153+
#### `--type`
154+
155+
Filter tests by type. If specified, only tests of the matching type are run.
156+
157+
**Possible values:**
158+
- `test` — regular tests (methods in classes)
159+
- `inline`[inline tests](/docs/inline-tests) (tests via `#[TestInline]`)
160+
- `bench` — benchmarks
161+
162+
**Examples:**
163+
```bash
164+
# Regular tests only
165+
testo run --type=test
166+
167+
# Inline tests only
168+
testo run --type=inline
169+
170+
# Benchmarks only
171+
testo run --type=bench
172+
173+
# Combine with other filters
174+
testo run --type=test --suite=Unit
175+
testo run --type=inline --filter=testLogin
176+
```
177+
178+
::: info Middleware and test types
179+
Middleware bound to a specific test type is excluded from the pipeline if the type doesn't match the one specified in `--type`.
180+
:::
181+
153182
### Combining Filters
154183

155184
**Examples:**

docs/filtering.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ $filter = new Filter(
1919
suites: ['Unit', 'Integration'],
2020
names: ['UserTest::testLogin', 'testAuthentication'],
2121
paths: ['tests/Unit/*', 'tests/Integration/*'],
22+
type: 'test',
2223
);
2324
```
2425

@@ -44,6 +45,12 @@ $filter = new Filter(
4445
- File or directory paths to filter by
4546
- Supports glob patterns: `*`, `?`, `[abc]`
4647

48+
**`type`**: `?non-empty-string`
49+
- Test type to filter by
50+
- Possible values: `test` (regular tests), `inline` (inline tests), `bench` (benchmarks), or other custom types
51+
- If not specified — all test types are run
52+
- Middleware bound to a specific type won't enter the pipeline if the type doesn't match
53+
4754
### Usage with Application
4855

4956
The `Filter` object can be passed to `Application::run()`:
@@ -77,17 +84,19 @@ Different filter types are combined with AND logic:
7784

7885
- `names: ['test1'], suites: ['Unit']` → matches if name is test1 **AND** suite is Unit
7986
- `names: ['UserTest'], paths: ['tests/Unit/*']` → matches if name is UserTest **AND** path matches tests/Unit/*
87+
- `names: ['test1'], type: 'inline'` → matches if name is test1 **AND** type is inline
8088

81-
**Formula**: `AND(OR(names), OR(paths), OR(suites))`
89+
**Formula**: `AND(OR(names), OR(paths), OR(suites), type)`
8290

8391
**Example:**
8492
```php
8593
$filter = new Filter(
8694
names: ['test1', 'test2'], // test1 OR test2
8795
paths: ['path1', 'path2'], // path1 OR path2
88-
suites: ['Unit', 'Critical'], // Unit OR Critical
96+
suites: ['Unit', 'Critical'], // Unit OR Critical
97+
type: 'test', // regular tests only
8998
);
90-
// Result: (test1 OR test2) AND (path1 OR path2) AND (Unit OR Critical)
99+
// Result: (test1 OR test2) AND (path1 OR path2) AND (Unit OR Critical) AND type=test
91100
```
92101

93102
## Name Filter Behavior

ru/docs/cli-reference.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Testo предоставляет три типа фильтров, которы
6767
**Логика комбинирования фильтров:**
6868
- Фильтры одного типа используют логику ИЛИ: `--filter=test1 --filter=test2` → test1 ИЛИ test2
6969
- Фильтры разных типов используют логику И: `--filter=test1 --suite=Unit` → test1 И Unit
70-
- Формула: `И(ИЛИ(filters), ИЛИ(paths), ИЛИ(suites))`
70+
- Формула: `И(ИЛИ(filters), ИЛИ(paths), ИЛИ(suites), type)`
7171

7272
Подробная информация о поведении фильтров в разделе [Фильтрация](/ru/docs/filtering).
7373

@@ -146,6 +146,35 @@ testo run --filter=UserTest --path="tests/Unit"
146146

147147
**Поведение фильтров:** Подробности в разделе [Фильтрация](/ru/docs/filtering).
148148

149+
#### `--type`
150+
151+
Фильтрация тестов по типу. Если указан, запускаются только тесты соответствующего типа.
152+
153+
**Возможные значения:**
154+
- `test` — обычные тесты (методы в классах)
155+
- `inline`[встроенные тесты](/ru/docs/inline-tests) (тесты через `#[TestInline]`)
156+
- `bench` — бенчмарки
157+
158+
**Примеры:**
159+
```bash
160+
# Только обычные тесты
161+
testo run --type=test
162+
163+
# Только встроенные тесты
164+
testo run --type=inline
165+
166+
# Только бенчмарки
167+
testo run --type=bench
168+
169+
# Комбинация с другими фильтрами
170+
testo run --type=test --suite=Unit
171+
testo run --type=inline --filter=testLogin
172+
```
173+
174+
::: info Мидлвари и тип тестов
175+
Мидлвари, привязанные к определённому типу тестов, исключаются из пайплайна, если тип не совпадает с указанным в `--type`.
176+
:::
177+
149178
### Комбинирование фильтров
150179

151180
**Примеры:**

ru/docs/filtering.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $filter = new Filter(
1515
suites: ['Unit', 'Integration'],
1616
names: ['UserTest::testLogin', 'testAuthentication'],
1717
paths: ['tests/Unit/*', 'tests/Integration/*'],
18+
type: 'test',
1819
);
1920
```
2021

@@ -40,6 +41,12 @@ $filter = new Filter(
4041
- Пути к файлам или директориям для фильтрации
4142
- Поддерживает glob-паттерны: `*`, `?`, `[abc]`
4243

44+
**`type`**: `?non-empty-string`
45+
- Тип тестов для фильтрации
46+
- Возможные значения: `test` (обычные тесты), `inline` (встроенные тесты), `bench` (бенчмарки), или другие пользовательские типы
47+
- Если не указан — запускаются все типы тестов
48+
- Мидлвари, привязанные к определённому типу, не попадут в пайплайн, если тип не совпадает
49+
4350
### Использование с Application
4451

4552
Объект `Filter` может быть передан в `Application::run()`:
@@ -73,17 +80,19 @@ $result = $app->run($filter);
7380

7481
- `names: ['test1'], suites: ['Unit']` → совпадает, если имя test1 **И** Test Suite - Unit
7582
- `names: ['UserTest'], paths: ['tests/Unit/*']` → совпадает, если имя UserTest **И** путь соответствует tests/Unit/*
83+
- `names: ['test1'], type: 'inline'` → совпадает, если имя test1 **И** тип - inline
7684

77-
**Формула**: `AND(OR(names), OR(paths), OR(suites))`
85+
**Формула**: `AND(OR(names), OR(paths), OR(suites), type)`
7886

7987
**Пример:**
8088
```php
8189
$filter = new Filter(
8290
names: ['test1', 'test2'], // test1 ИЛИ test2
8391
paths: ['path1', 'path2'], // path1 ИЛИ path2
84-
suites: ['Unit', 'Critical'], // Unit ИЛИ Critical
92+
suites: ['Unit', 'Critical'], // Unit ИЛИ Critical
93+
type: 'test', // только обычные тесты
8594
);
86-
// Результат: (test1 ИЛИ test2) И (path1 ИЛИ path2) И (Unit ИЛИ Critical)
95+
// Результат: (test1 ИЛИ test2) И (path1 ИЛИ path2) И (Unit ИЛИ Critical) И type=test
8796
```
8897

8998
## Поведение фильтра по именам

0 commit comments

Comments
 (0)