<p>You can use another verifier. Inspec should have a reporter that will report in the correct format. <a href="https://molecule.readthedocs.io/en/stable/configuration.html#inspec" rel="nofollow noreferrer">https://molecule.readthedocs.io/en/stable/configuration.html#inspec</a></p>

CC BY-SA 4.0
2019-08-27T09:33:38.417Z
Inspec is to test a machine state, services, api results, whatever, but absolutely not for code coverage in Sonar.
Tensibai
CC BY-SA 4.0
2019-08-26T19:36:07.633Z
2019-08-26T19:36:07.633Z
Zachary
<p>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.</p>

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

CC BY-SA 4.0
2019-07-26T12:37:53.160Z
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
<ansible><code-coverage><sonarqube><molecule>
Is there any way of getting code coverage with molecule?
Yoiro
# Is there any way of getting code coverage with molecule?

(Asked by: username_0 on 2019-05-29)

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

**Tags:** ansible, code-coverage, sonarqube, molecule

> **Comments:**
> **username_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!  

---

## 1 answers

### Answer by username_2 on 2019-08-26. Score: -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>

> **Comments:**
> **username_3**: Inspec is to test a machine state, services, api results, whatever, but absolutely not for code coverage in Sonar.  

---

