diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6c7e3ab0..adbe47503 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,50 @@ started: 👩‍⚖️ When contributing code to this project, you may be asked to agree to our [Contributor License Agreement]. +## Testing + +The [devcontainer CLI] is used to run the tests in this repository. Install it with: + +```bash +npm install -g @devcontainers/cli +``` + +### Run all tests + +To run the tests for **every** Feature in this repository, run the following commands from the root of the repository: + +```bash +# Run auto-generated and scenario tests for every Feature +devcontainer features test . + +# Run the global test scenarios +devcontainer features test --global-scenarios-only . +``` + +### Test a specific Feature + +To test a specific Feature (e.g. `go`): + +```bash +devcontainer features test -f go . +``` + +### Test against a specific base image + +By default tests run against `mcr.microsoft.com/devcontainers/base:ubuntu`. Use the `--base-image` (or `-i`) flag to specify a different image: + +```bash +devcontainer features test -f go -i ubuntu:focal . +``` + +### Run only scenario tests + +Use `--skip-autogenerated` to run only the [scenario tests] defined in `test//scenarios.json`: + +```bash +devcontainer features test -f go --skip-autogenerated . +``` + [our dev container community Slack channel]: https://aka.ms/devcontainer_community [open an issue]: https://github.com/devcontainers/features/issues/new @@ -57,4 +101,6 @@ started: [contributor license agreement]: https://opensource.microsoft.com/cla/ [Test your changes using `devcontainer features test`]: https://github.com/devcontainers/cli/blob/main/docs/features/test.md [semver]: https://semver.org/ +[devcontainer CLI]: https://github.com/devcontainers/cli +[scenario tests]: https://github.com/devcontainers/cli/blob/main/docs/features/test.md#scenarios