5

I'm currently working on testing Ansible roles with Molecule. I have one role with 2 scenarios that are executed in Jenkins but just before that, those are submitted to a SonarQube analysis. So I installed the YAML plugin for it to recognize the files, but now, I am asked to add code coverage to these reports.

I'm wondering if there's a way of having code coverage using Molecule with its default stack (Docker/Testinfra)?

1
  • I have wondered a lot about this too, but I would presume that this is not available out of the box. In order to calculate coverage, you need to ensure that functions are tested - but these functions are Ansible tasks. Since I can't really see a 1-1 mapping between Infra tests and Ansible tasks, I don't see how this could be done. However, I'd love to hear counter arguments! Commented Jul 26, 2019 at 12:37

1 Answer 1

-1

You can use another verifier. Inspec should have a reporter that will report in the correct format. https://molecule.readthedocs.io/en/stable/configuration.html#inspec

1
  • 1
    Inspec is to test a machine state, services, api results, whatever, but absolutely not for code coverage in Sonar.
    – Tensibai
    Commented Aug 27, 2019 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.