Unit tests

All of the unit tests are located within the directory tree starting at test/units. These tests should all be self-contained and do not require access to external resources. Running the tests is as simple as executing make tests from the root of the Ansible source checkout. This will test much of the code base, including the module code.

Executing the tests may require the installation of additional software. When using a Python virtualenv to manage Python software installations, it's best to create a new venv to use for testing Ansible–one that does not have Ansible installed in it.

To target a specific set of tests to run, the pytest (sometimes accessed as py.test) utility can be called directly, with a path provided to a directory or a specific file to test. In this example, just the parsing unit tests are executed:

As can be seen in the screenshot, the py.test utility is running through the defined unit tests and will report any errors it finds, aiding you greatly in checking any code you might be planning to submit.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181