Ansible-Test |Testing The Automation Code Becomes More Important | Inofgen Labs
Ansible-Test |Testing The Automation Code Becomes More Important | Inofgen Labs

Ansible-Test |Testing The Automation Code Becomes More Important | Inofgen Labs

Introduction to ansible-test

As automation becomes increasingly important in more business cases, testing the automation code becomes more important. This is where ansible-test comes in: developers may use ansible-test to create testing processes that integrate with source code repositories to test their Ansible Content Collections for sanity, unit, and integration tests.

Collection developers can utilise ansible-test, a cli tool included with both ansible-core and ansible-base, to test their Collection and its content. From linting module documentation and code to performing unit and integration tests, the ansible-test can handle a wide range of testing activities.

How to run an ansible-test?

With Ansible-2.9's wide release of Ansible Content Collections, a user can now use ansible-test to test the collection itself. In order for ansible-test to execute tests on the Collection, it must be run from the collection root or below.

If you try to execute ansible-test outside of the aforementioned directory norms, you'll get the following error:

No alt text provided for this image

You can see how a collection root appears to ansible-test in the output above; it must be in the form of:

No alt text provided for this image

When you install a collection from Ansible Galaxy or Automation Hub, the default installation location is: {...}/ansible_collections/{namespace}/{collection}/ , which already satisfies the above directory convention.

Even if you specify the installation path to the ansible-galaxy cli (using the -p option), it will also install a collection inside the ansible_collections directory by creating one in the given path, like below:

No alt text provided for this image

How to test your collection using ansible test?

ansible-test allows you to conduct several types of tests on your Collections. These tests are classified as follows:

  • Sanity Tests
  • Unit Tests
  • Integration Tests
  • We'll go over each of these tests thoroughly.

?Visit Us:?corp.infogen-labs.com?

Social Media:?Instagram?|?Facebook?|?LinkedIn?|?YouTube?|?Twitter?

要查看或添加评论,请登录

Ciklum India的更多文章

社区洞察

其他会员也浏览了