What is `ansible-test` and when do you need it?
AdvancedProductionTesting, CI/CD and Quality
Answer
ansible-test ships with ansible-core and is the test runner for collections. It expects the collection to sit at ansible_collections/<namespace>/<name>/.
ansible-test sanity --docker default # docs, imports, argument specs, Python compatibility
ansible-test units --docker default # pytest unit tests
ansible-test integration --docker default # targets under tests/integration/targets
Sanity tests catch things like module documentation not matching argument_spec, missing __future__ imports and code that breaks on a supported Python version. If you only write roles and playbooks you do not need it; Molecule and ansible-lint cover you. Once you publish a collection with custom modules or plugins, run ansible-test sanity in CI for every supported ansible-core version.
More on Testing, CI/CD and Quality
What does a testing pyramid look like for Ansible code?BeginnerHow do you roll out `ansible-lint` profiles across a team without blocking everyone?IntermediateWhen do you use `skip_list`, `warn_list` and `# noqa`?IntermediateHow do you set up pre-commit hooks for an Ansible repo?BeginnerHow is a Molecule scenario laid out, and what does `molecule test` actually run?IntermediateDocker, Podman or real VMs as the Molecule driver: how do you choose?Advanced