ワンクリックで
run-tests
// Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing.
// Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing.
| name | run-tests |
| description | Runs and writes tests (sanity, unit, integration) for this Ansible collection using ansible-test. Use when asked to run, check, or write tests for a module or utility. Do not use for PR reviews or questions unrelated to testing. |
Run and write tests for this Ansible collection. Covers sanity, unit, and integration tests using ansible-test.
TRIGGER when:
DO NOT TRIGGER when:
.agents/skills/pr-review/SKILL.md instead)All tests run inside Docker/Podman via ansible-test --docker. No local package installation is needed. The collection must be installed at ansible_collections/community/rabbitmq/ (relative to a directory on ANSIBLE_COLLECTIONS_PATHS) for imports to resolve correctly.
Checks style, documentation, and imports for a changed file:
ansible-test sanity plugins/modules/rabbitmq_user.py --docker -vvv
Runs unit tests for changed files:
ansible-test units tests/unit/plugins/modules/test_rabbitmq_user.py --docker -vvv
Unit tests live under tests/unit/plugins/ and use the PyTest framework. Every new function or class method MUST have a corresponding unit test.
Runs integration tests against a target environment (started by Docker):
ansible-test integration rabbitmq_user --docker default -vvv
ansible-test integration rabbitmq_exchange --docker default -vvv
Integration tests live under tests/integration/targets/<module_name>/.
| Change type | Sanity | Unit | Integration |
|---|---|---|---|
| New module | yes | yes | yes |
| New parameter | yes | if logic changed | yes |
| Bug fix | yes | yes | yes |
| Refactoring | yes | yes | no |
| Documentation only | yes | no | no |
Every integration test target must follow this sequence:
register: resultresult using ansible.builtin.assertregister: result → ansible.builtin.assertcheck_mode: true as well- name: Create exchange in check mode
check_mode: true
community.rabbitmq.rabbitmq_exchange:
name: test_exchange
type: direct
state: present
register: result
- name: Assert changed
ansible.builtin.assert:
that:
- result is changed
- name: Create exchange in real mode
community.rabbitmq.rabbitmq_exchange:
name: test_exchange
type: direct
state: present
register: result
- name: Assert changed
ansible.builtin.assert:
that:
- result is changed
Tests must also cover:
result is not changed.state: absent: where applicable, remove the resource and assert it is gone.