QUESTION: Recommended way to run unit tests in Travis

Our team is in the process of submitting a module with unit tests to https://github.com/ansible/ansible-modules-extras and we have a few questions about how to get it to run with the rest of the projects build steps in Travis and whether the community has a preferred way of getting these things done.

  • Is nose still the preferred testing library to use or is there a move to py.test or some other lib?

  • Can we add a test-requirements.txt to the root dir so that it’s easier to maintain the required libs for unit testing?

  • Can we add an item under the script section of .travis.yml that executes our unit tests?

Hoping for some clarification/guidance from the team. Thank you!

Mark,

Nearly all of the module unit tests (and all of the integration tests) currently reside in the main Ansible repository in the test/units and test/integration directories. These tests are run as part of our CI process on Shippable. You’ll need to submit a separate PR for the unit tests, which we can merge after your module has been merged. This process will get easier once we’ve combined the repositories, as you’ll be able to submit your tests along with your module in a single PR.

To answer your other questions:

  • We’re still using nose for our unit tests.

  • Requirements for unit tests can be added to test/utils/shippable/sanity-requirements.txt and will be picked up by Shippable when running tests via the test/utils/shippable/sanity.sh script.

  • We’ve mostly migrated away from Travis to Shippable, so we shouldn’t be adding anything new to .travis.yml. If you add your unit tests to the existing ones, you shouldn’t need to make any other changes.

  • Matt Clay

Thanks for the clarification here and on IRC, Matt! I’ve updated my notes to align with your answers and suggestions. http://www.relaxdiego.com/2016/06/writing-ansible-modules-with-tests.html