|
| 1 | +# Command Line Interface |
| 2 | + |
| 3 | +This document describes the command line interface for Testo. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +### `run` |
| 8 | + |
| 9 | +Execute test suites with optional filtering and output formatting. |
| 10 | + |
| 11 | +This is the default command and can be omitted when using flags. |
| 12 | + |
| 13 | +```bash |
| 14 | +./bin/testo run [options] |
| 15 | +./bin/testo [options] # run is optional |
| 16 | +``` |
| 17 | + |
| 18 | +**Examples:** |
| 19 | +```bash |
| 20 | +# Explicit run command |
| 21 | +./bin/testo run |
| 22 | +./bin/testo run --suite=Unit |
| 23 | + |
| 24 | +# Implicit run command (default) |
| 25 | +./bin/testo |
| 26 | +./bin/testo --suite=Unit |
| 27 | +``` |
| 28 | + |
| 29 | +## Common Configuration Flags |
| 30 | + |
| 31 | +### `--config` |
| 32 | + |
| 33 | +Specify path to configuration file. |
| 34 | + |
| 35 | +**Default:** `./testo.php` |
| 36 | + |
| 37 | +**Examples:** |
| 38 | +```bash |
| 39 | +./bin/testo run --config=./custom-testo.php |
| 40 | +./bin/testo run --suite=Integration --config=./ci-testo.php |
| 41 | +``` |
| 42 | + |
| 43 | +## Running Tests |
| 44 | + |
| 45 | +### Output Formatting |
| 46 | + |
| 47 | +#### `--teamcity` |
| 48 | + |
| 49 | +Enable TeamCity service message format for JetBrains IDE integration. |
| 50 | + |
| 51 | +Used by the [Testo plugin](https://plugins.jetbrains.com/plugin/28842-testo) for PHPStorm/IntelliJ IDEA and TeamCity CI server. |
| 52 | + |
| 53 | +**Examples:** |
| 54 | +```bash |
| 55 | +./bin/testo --teamcity |
| 56 | +./bin/testo --suite=Unit --teamcity |
| 57 | +``` |
| 58 | + |
| 59 | +### Filtering |
| 60 | + |
| 61 | +Testo provides three types of filters that can be combined to selectively run tests. |
| 62 | + |
| 63 | +**Filter Combination Logic:** |
| 64 | +- Same type filters use OR logic: `--filter=test1 --filter=test2` → test1 OR test2 |
| 65 | +- Different type filters use AND logic: `--filter=test1 --suite=Unit` → test1 AND Unit |
| 66 | +- Formula: `AND(OR(filters), OR(paths), OR(suites))` |
| 67 | + |
| 68 | +For detailed information about filtering behavior, see [Filtering](/docs/filtering). |
| 69 | + |
| 70 | +#### `--suite` |
| 71 | + |
| 72 | +Filter tests by test suite name. Suites are defined in configuration. |
| 73 | + |
| 74 | +**Repeatable:** Yes (OR logic) |
| 75 | + |
| 76 | +**Examples:** |
| 77 | +```bash |
| 78 | +# Single suite |
| 79 | +./bin/testo run --suite=Unit |
| 80 | + |
| 81 | +# Multiple suites |
| 82 | +./bin/testo run --suite=Unit --suite=Integration |
| 83 | +``` |
| 84 | + |
| 85 | +#### `--path` |
| 86 | + |
| 87 | +Filter test files by glob patterns. Supports wildcards: `*`, `?`, `[abc]` |
| 88 | + |
| 89 | +**Repeatable:** Yes (OR logic) |
| 90 | + |
| 91 | +**Note:** Asterisk `*` is automatically appended if the path doesn't end with a wildcard. |
| 92 | +- `tests/Unit` becomes `tests/Unit*` |
| 93 | +- `tests/Unit/` becomes `tests/Unit/*` |
| 94 | + |
| 95 | +**Examples:** |
| 96 | +```bash |
| 97 | +# Matches tests/Unit* |
| 98 | +./bin/testo run --path="tests/Unit" |
| 99 | + |
| 100 | +# Matches tests/Unit/*Test.php |
| 101 | +./bin/testo run --path="tests/Unit/*Test.php" |
| 102 | + |
| 103 | +# Multiple paths |
| 104 | +./bin/testo run --path="tests/Unit" --path="tests/Integration" |
| 105 | + |
| 106 | +# Nested directories |
| 107 | +./bin/testo run --path="tests/*/Security/*Test.php" |
| 108 | +``` |
| 109 | + |
| 110 | +#### `--filter` |
| 111 | + |
| 112 | +Filter tests by class, method, or function names. |
| 113 | + |
| 114 | +**Repeatable:** Yes (OR logic) |
| 115 | + |
| 116 | +**Supported Formats:** |
| 117 | +- **Method**: `ClassName::methodName` or `Namespace\ClassName::methodName` |
| 118 | +- **FQN**: `Namespace\ClassName` or `Namespace\functionName` |
| 119 | +- **Fragment**: `methodName`, `functionName`, or `ShortClassName` |
| 120 | + |
| 121 | +**Examples:** |
| 122 | +```bash |
| 123 | +# Specific method |
| 124 | +./bin/testo run --filter=UserTest::testLogin |
| 125 | + |
| 126 | +# Entire class |
| 127 | +./bin/testo run --filter=UserTest |
| 128 | + |
| 129 | +# By FQN |
| 130 | +./bin/testo run --filter=Tests\Unit\UserTest |
| 131 | + |
| 132 | +# Method name across all classes |
| 133 | +./bin/testo run --filter=testLogin |
| 134 | + |
| 135 | +# Multiple filters (OR) |
| 136 | +./bin/testo run --filter=UserTest::testCreate --filter=UserTest::testUpdate |
| 137 | + |
| 138 | +# Combine with other filters (AND) |
| 139 | +./bin/testo run --filter=testAuthentication --suite=Unit |
| 140 | +./bin/testo run --filter=UserTest --path="tests/Unit" |
| 141 | +``` |
| 142 | + |
| 143 | +**Filter Behavior:** See [Filtering](/docs/filtering) for details. |
| 144 | + |
| 145 | +### Combining Filters |
| 146 | + |
| 147 | +**Examples:** |
| 148 | +```bash |
| 149 | +# Name AND suite |
| 150 | +./bin/testo run --filter=testLogin --suite=Unit |
| 151 | + |
| 152 | +# Name AND path |
| 153 | +./bin/testo run --filter=UserTest --path="tests/Unit" |
| 154 | + |
| 155 | +# All three types (AND) |
| 156 | +./bin/testo run --filter=testImportant --path="tests/Unit" --suite=Critical |
| 157 | + |
| 158 | +# Multiple values with multiple types |
| 159 | +./bin/testo run \ |
| 160 | + --filter=testCreate --filter=testUpdate \ |
| 161 | + --path="tests/Unit" --path="tests/Integration" \ |
| 162 | + --suite=Critical |
| 163 | +``` |
| 164 | + |
| 165 | +## Exit Codes |
| 166 | + |
| 167 | +- `0` (SUCCESS): All tests passed |
| 168 | +- `1` (FAILURE): One or more tests failed |
| 169 | +- `2` (INVALID): Invalid command or configuration |
0 commit comments