Skip to content

Commit e1e56e3

Browse files
committed
CONTRIBUTING: add minimal info about bashunit tests
1 parent db4f766 commit e1e56e3

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

.github/CONTRIBUTING.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Thank you for your interest in contributing to PHP_CodeSniffer!
1818
* [Finding Something to Work on](#finding-something-to-work-on)
1919
* [Getting Started](#getting-started)
2020
* [While Working on a Patch](#while-working-on-a-patch)
21-
* [Writing Tests](#writing-tests)
21+
* [Writing Unit/Integration Tests](#writing-unitintegration-tests)
22+
* [Writing End-to-End Tests](#writing-end-to-end-tests)
2223
* [Submitting Your Pull Request](#submitting-your-pull-request)
2324
* [Licensing](#licensing)
2425

@@ -268,7 +269,7 @@ To help you with this, a number of convenience scripts are available:
268269
N.B.: You can ignore any skipped tests as these are for external tools.
269270

270271

271-
### Writing Tests
272+
### Writing Unit/Integration Tests
272273

273274
Tests for the PHP_CodeSniffer engine can be found in the `tests/Core` directory.
274275
Tests for individual sniffs can be found in the `src/Standards/[StandardName]/Tests/[Category]/` directory.
@@ -376,7 +377,7 @@ To run the tests specific to the use of `PHP_CODESNIFFER_CBF === true`:
376377
vendor/bin/phpunit --group CBF --exclude-group nothing
377378
```
378379

379-
#### Other notes about writing tests
380+
#### Other notes about writing unit/integration tests
380381

381382
* The `Config` class uses a number of static properties and can have a performance impact on the tests too.
382383
To get round both these issues, use the `ConfigDouble` class instead.
@@ -387,6 +388,24 @@ To run the tests specific to the use of `PHP_CODESNIFFER_CBF === true`:
387388
* When using data providers, define them immediately below the corresponding test method.
388389
* When a test method has only one data provider, it is considered best practice to closely couple the test and data provider methods via their names. I.e. the data provider's name should match the test method name, replacing the "test" prefix with "data". For example, the data provider for a method named `testSomething()` should be `dataSomething()`.
389390

391+
392+
### Writing End-to-End Tests
393+
394+
Bash-based end-to-end tests can be written using the [Bashunit](https://bashunit.typeddevs.com/) test tooling.
395+
396+
To install bashunit, follow the [installation guide](https://bashunit.typeddevs.com/installation).
397+
398+
You can then run the bashunit tests on Linux/Mac/WSL, like so:
399+
```bash
400+
./lib/bashunit -p tests/EndToEnd
401+
```
402+
403+
> Note: these tests will not run in the Windows native CMD shell. When on Windows, either use WSL or use the "git bash" shell.
404+
405+
When writing end-to-end tests, please use fixtures for the "files under scan" to make the tests stable.
406+
These fixtures can be placed in the `tests/EndToEnd/Fixtures` subdirectory.
407+
408+
390409
### Submitting Your Pull Request
391410

392411
Some guidelines for submitting pull requests (PRs) and improving the chance that your PR will be merged:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ composer.lock
99
phpstan.neon
1010
/node_modules/
1111
/tests/EndToEnd/Fixtures/*.fixed
12+
/lib/

0 commit comments

Comments
 (0)