You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0cc3fd1
Browse filesBrowse the repository at this point in the historyBrowse files
Prepending with the double dash is needed because the arguments would otherwise be sent to Composer itself, not the tool that Composer executes.
228
231
232
+
The same mechanism works for narrowing a run down further, or for bailing out early:
233
+
```bash
234
+
# A single scenario, identified by the line it starts on.
235
+
composer behat -- features/cli-info.feature:12
236
+
237
+
# Every scenario carrying a given tag.
238
+
composer behat -- --tags=@require-wp-5.0
239
+
240
+
# Stop at the first failing scenario instead of running the whole suite.
241
+
composer behat -- --stop-on-failure
242
+
243
+
# Re-run only the scenarios that failed the last time.
244
+
composer behat-rerun
245
+
```
246
+
247
+
### Linting the feature files
248
+
249
+
`composer lint-gherkin` checks `features/` with
250
+
[gherkin-lint-plus](https://www.npmjs.com/package/gherkin-lint-plus), against the
251
+
`.gherkin-lintrc` ruleset shipped with this package. A project that needs
252
+
different rules can override it by committing its own `.gherkin-lintrc`.
253
+
254
+
The linter is a Node package, so it is run through `npx` and needs Node.js 20 or
255
+
later. Where `npx` is not available the check reports that it is skipping, rather
256
+
than failing a suite that is otherwise entirely PHP. Its version is pinned in
257
+
this package's `package.json`, which exists only to hold that pin.
258
+
259
+
### Controlling the amount of output
260
+
261
+
Two environment variables make the test tools less chatty. Both are unset by default, which leaves the output exactly as it has always been.
262
+
263
+
*`NO_COLOR` (the [no-color.org](https://no-color.org/) convention) turns off the ANSI color codes in the output of every runner. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
264
+
*`WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. This covers the analysis of the PHP files themselves; the checks over the PHP blocks embedded in feature files keep their own reports, which are rewritten to point back at the feature file a block came from. Behat's own output is already minimal, so it is unaffected.
265
+
266
+
`NO_COLOR` also covers the Gherkin linter, which colors its report unconditionally and has no plain output format of its own.
267
+
268
+
```bash
269
+
NO_COLOR=1 WP_CLI_TEST_QUIET=1 composer phpstan
270
+
```
271
+
272
+
This is worth setting permanently in environments that read the output back rather than display it, such as an AI coding agent's shell:
273
+
274
+
```bash
275
+
export NO_COLOR=1
276
+
export WP_CLI_TEST_QUIET=1
277
+
```
278
+
229
279
### Controlling the test environment
230
280
231
281
#### WordPress Version
@@ -241,6 +291,13 @@ Here's how to run your tests against the latest trunk version of WordPress:
241
291
WP_VERSION=trunk composer behat
242
292
```
243
293
294
+
Resolving `latest`, or a `X.Y` version without a patch number, needs the
295
+
WordPress versions data, which is fetched once and cached in the system temp
296
+
directory for a day. Repeated runs do not repeat the request, and a run without
297
+
connectivity falls back to the last known copy.
298
+
`WP_CLI_TEST_WP_VERSION_CACHE_TTL` sets the lifetime of that cache in seconds;
299
+
`0` fetches it every time.
300
+
244
301
#### WordPress Archive
245
302
246
303
Instead of downloading WordPress from WordPress.org, you can run the tests against an arbitrary
Prepending with the double dash is needed because the arguments would otherwise be sent to Composer itself, not the tool that Composer executes.
239
242
243
+
The same mechanism works for narrowing a run down further, or for bailing out early:
244
+
```bash
245
+
# A single scenario, identified by the line it starts on.
246
+
composer behat -- features/cli-info.feature:12
247
+
248
+
# Every scenario carrying a given tag.
249
+
composer behat -- --tags=@require-wp-5.0
250
+
251
+
# Stop at the first failing scenario instead of running the whole suite.
252
+
composer behat -- --stop-on-failure
253
+
254
+
# Re-run only the scenarios that failed the last time.
255
+
composer behat-rerun
256
+
```
257
+
258
+
### Linting the feature files
259
+
260
+
`composer lint-gherkin` checks `features/` with
261
+
[gherkin-lint-plus](https://www.npmjs.com/package/gherkin-lint-plus), against the
262
+
`.gherkin-lintrc` ruleset shipped with this package. A project that needs
263
+
different rules can override it by committing its own `.gherkin-lintrc`.
264
+
265
+
The linter is a Node package, so it is run through `npx` and needs Node.js 20 or
266
+
later. Where `npx` is not available the check reports that it is skipping, rather
267
+
than failing a suite that is otherwise entirely PHP. Its version is pinned in
268
+
this package's `package.json`, which exists only to hold that pin.
269
+
270
+
### Controlling the amount of output
271
+
272
+
Two environment variables make the test tools less chatty. Both are unset by default, which leaves the output exactly as it has always been.
273
+
274
+
*`NO_COLOR` (the [no-color.org](https://no-color.org/) convention) turns off the ANSI color codes in the output of every runner. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
275
+
*`WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. This covers the analysis of the PHP files themselves; the checks over the PHP blocks embedded in feature files keep their own reports, which are rewritten to point back at the feature file a block came from. Behat's own output is already minimal, so it is unaffected.
276
+
277
+
`NO_COLOR` also covers the Gherkin linter, which colors its report unconditionally and has no plain output format of its own.
278
+
279
+
```bash
280
+
NO_COLOR=1 WP_CLI_TEST_QUIET=1 composer phpstan
281
+
```
282
+
283
+
This is worth setting permanently in environments that read the output back rather than display it, such as an AI coding agent's shell:
284
+
285
+
```bash
286
+
export NO_COLOR=1
287
+
export WP_CLI_TEST_QUIET=1
288
+
```
289
+
240
290
### Controlling the test environment
241
291
242
292
#### WordPress Version
@@ -252,6 +302,13 @@ Here's how to run your tests against the latest trunk version of WordPress:
252
302
WP_VERSION=trunk composer behat
253
303
```
254
304
305
+
Resolving `latest`, or a `X.Y` version without a patch number, needs the
306
+
WordPress versions data, which is fetched once and cached in the system temp
307
+
directory for a day. Repeated runs do not repeat the request, and a run without
308
+
connectivity falls back to the last known copy.
309
+
`WP_CLI_TEST_WP_VERSION_CACHE_TTL` sets the lifetime of that cache in seconds;
310
+
`0` fetches it every time.
311
+
255
312
#### WordPress Archive
256
313
257
314
Instead of downloading WordPress from WordPress.org, you can run the tests against an arbitrary
0 commit comments