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)?

Yoiro
  • 151
  • 3
  • 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! – Bruce Becker Jul 26 '19 at 12:37

1 Answers1

-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

Zachary
  • 117
  • 3
  • 1
    Inspec is to test a machine state, services, api results, whatever, but absolutely not for code coverage in Sonar. – Tensibai Aug 27 '19 at 09:33