Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Go projects should use the go-acc tool (``go get -v github.com/ory/go-acc``) to run tests and generate the file coveragestatistics.txt.  This yields better results than standard features in golang versions 1.12 and 1.13.  Here's an example:

   go-acc $(go list ./... | grep -vE '(/tests|/enums)' )

This should create the output file coverage.txt, which can be consumed by the Sonar scanner. However modules are not supported yet by the Sonar Scanner. If you rewrite the module name in the coverage report to the name of the directory with source code, Sonar will match the coverage data with its source analysis.  Also seeThe problem and some workarounds are described here: https://jira.sonarsource.com/browse/SONARSLANG-450

...

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

This should create the output file target/jacoco.exec, which can be consumed by the Sonar scanner.

Configure a Python Project for Code Coverage

...

First, add required packages within the  `[testenv]` block:

deps=
pytest
coverage
pytest-cov

Second, add the following commands within the `[testenv]` block:

commands =
pytest --cov dir-name --cov-report xml --cov-report term-missing --cov-report html --cov-fail-under=70
coverage xml -i

This should create the output file coverage.xml, which can be consumed by the Sonar scanner.

Setting up development environment

...