From 1b0625f51c43453f52027c3d63c6259e855b41ba Mon Sep 17 00:00:00 2001 From: Peeter Piegaze <61758048+peeter-piegaze-sonarsource@users.noreply.github.com> Date: Mon, 23 May 2022 17:06:58 +0200 Subject: [PATCH] Minor fixes (#5945) --- .../test-coverage/c-family-test-coverage.md | 31 ++++++++++--------- .../test-coverage/dotnet-test-coverage.md | 13 ++++---- .../test-coverage/java-test-coverage.md | 11 +++---- .../javascript-typescript-test-coverage.md | 9 +++--- .../test-coverage/php-test-coverage.md | 11 +++---- .../test-coverage/python-test-coverage.md | 11 +++---- .../test-coverage/test-coverage-parameters.md | 4 +-- 7 files changed, 42 insertions(+), 48 deletions(-) diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/c-family-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/c-family-test-coverage.md index a7f9ca70836..512d06f652e 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/c-family-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/c-family-test-coverage.md @@ -6,14 +6,13 @@ url: /analysis/test-coverage/c-family-test-coverage/ SonarQube supports the reporting of test coverage information as part of the analysis of your C/C++/Objective-C project. However, SonarQube does not generate the coverage report itself. -Instead, you must use a third-party tool to produce the coverage report(s) as part of your build process (before the analysis step). -Later, during the analysis steps, the scanner picks up this report and sends it to SonarQube. -The coverage is then displayed on your SonarQube project dashboard along with the other analysis metrics. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. ## Adjust your setup -To enable coverage you need to: +To enable coverage, you need to: * Adjust your build process so that the coverage tool generates the report(s). This is done just after your unit tests as part of the clean build required to run analysis. @@ -23,7 +22,9 @@ To enable coverage you need to: ## Add coverage to your build process -For C/C++/Objective-C projects SonarCloud supports a number of coverage tools. Each has an associated analysis parameter that must be set to the location of the coverage report that is produced by the tool. The parameters are: +For C/C++/Objective-C projects, SonarQube supports a number of coverage tools. +Each has an associated analysis parameter that must be set to the location of the coverage report that is produced by the tool. +The parameters are: * `sonar.cfamily.llvm-cov.reportPath` * `sonar.cfamily.vscoveragexml.reportsPath` @@ -33,23 +34,23 @@ For C/C++/Objective-C projects SonarCloud supports a number of coverage tools. E Assuming that you have already set up your project, you will have seen the example projects (_without coverage_) referenced in the in-product tutorials: [sonarsource-cfamily-examples](https://github.com/orgs/sonarsource-cfamily-examples/). -To help you add coverage to your project, we also provide, in the same GitHub organization, a few example repositories _with coverage_. +In the same GitHub organization, you will also find example repositories that provide guidance on how to _add coverage_ to an already-configured project. +These examples do not explicitly describe every possible combination of tooling and platform but do cover the most significant variants. +You may need to adapt them slightly: -Unlike the examples without coverage, not every possible combination of tooling and platform are represented and the examples given are only for SonarCloud. However, adapring them to your needs shuld not be difficult: +* [Visual Studio Coverage example on GitHub Actions](https://github.com/sonarsource-cfamily-examples/windows-msbuild-vscoverage-gh-actions-sc) -* [windows-msbuild-vscoverage-gh-actions-sc](https://github.com/sonarsource-cfamily-examples/windows-msbuild-vscoverage-gh-actions-sc) +* [Visual Studio Coverage example on Azure DevOps](https://github.com/sonarsource-cfamily-examples/windows-msbuild-vscoverage-azure-sc) -* [windows-msbuild-vscoverage-azure-sc](https://github.com/sonarsource-cfamily-examples/windows-msbuild-vscoverage-azure-sc) +* [XCode Coverage example](https://github.com/sonarsource-cfamily-examples/macos-xcode-coverage-gh-actions-sc) -* [macos-xcode-coverage-gh-actions-sc](https://github.com/sonarsource-cfamily-examples/macos-xcode-coverage-gh-actions-sc) +* [llvm-cov example](https://github.com/sonarsource-cfamily-examples/linux-cmake-llvm-cov-gh-actions-sc) -* [linux-cmake-llvm-cov-gh-actions-sc](https://github.com/sonarsource-cfamily-examples/linux-cmake-llvm-cov-gh-actions-sc) +* [gcovr example](https://github.com/sonarsource-cfamily-examples/linux-cmake-gcovr-gh-actions-sc) -* [linux-cmake-gcovr-gh-actions-sc](https://github.com/sonarsource-cfamily-examples/linux-cmake-gcovr-gh-actions-sc) +* [gcov example](https://github.com/sonarsource-cfamily-examples/linux-autotools-gcov-travis-sc) -* [linux-autotools-gcov-travis-sc](https://github.com/sonarsource-cfamily-examples/linux-autotools-gcov-travis-sc) - -These examples include the major free-to-use coverage tools for C/C++/Objective-C (VS Coverage, XCode Coverage, LLVM-COV, GCOVR, and GCOV). For information on the populat commercial Bullseye product, see https://www.bullseye.com/. +These examples include the major free-to-use coverage tools for C/C++/Objective-C (VS Coverage, XCode Coverage, LLVM-COV, GCOVR, and GCOV). For information on the popular commercial Bullseye product, see https://www.bullseye.com/. ## Coverage parameters can be set in multiple places diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/dotnet-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/dotnet-test-coverage.md index e5afe20b00f..d81e5afc636 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/dotnet-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/dotnet-test-coverage.md @@ -5,10 +5,9 @@ url: /analysis/test-coverage/dotnet-test-coverage/ SonarQube supports the reporting of test coverage information as part of the analysis of your .NET project. -However, SonarQube does not compile the coverage report itself. -Instead, you must set up a third-party tool to produce the coverage report as part of your build process. -During the analysis, the scanner (in this case, the [SonarScanner for .NET](/analysis/scan/sonarscanner-for-msbuild/)) picks up this report and sends it to SonarQube. -The coverage is then displayed on your SonarQube project dashboard, along with the other analysis metrics. +However, SonarQube does not generate the coverage report itself. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. SonarQube supports the following .NET test coverage tools: @@ -93,7 +92,7 @@ because this tool’s output format is the same as the Visual Studio Code Covera We use the `-f xml` parameter to specify that the output format is in XML. -### **dotCover** +### dotCover To use [dotCover](https://www.jetbrains.com/help/dotcover/dotCover__Coverage_Analysis_on_Third-Party_Server.html) you must install it as a global dotnet tool: @@ -138,7 +137,7 @@ dotnet sonarscanner end /d:sonar.login="" Note that we specify the path to the reports using `sonar.cs.opencover.reportsPaths` because we are using OpenCover. -### **Coverlet** +### Coverlet To use Coverlet, you must install it as a global dotnet tool: @@ -221,7 +220,7 @@ steps: - task: SonarQubeAnalyze@1 ``` -## **VB.NET** +## VB.NET The examples above are all for C# projects. For VB.NET projects the setup is identical except that you would use these parameters: diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/java-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/java-test-coverage.md index c87d8c3d186..59bbdaafcf9 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/java-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/java-test-coverage.md @@ -5,10 +5,9 @@ url: /analysis/test-coverage/java-test-coverage/ SonarQube supports the reporting of test coverage as part of the analysis of your Java project. -However, SonarQube does not compile the coverage report itself. -Instead, you must set up a third-party tool to produce the coverage report as part of your build process. -The SonarScanner will pick up this report and send it to SonarQube where it will be displayed on your project dashboard -along with the other analysis metrics. +However, SonarQube does not generate the coverage report itself. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. For Java projects, SonarQube directly supports the JaCoCo coverage tool (see [Generic Test Data](/analysis/test-coverage/generic-test/) for information on integrating other coverage tools). @@ -16,7 +15,7 @@ For Java projects, SonarQube directly supports the JaCoCo coverage tool ## Adjust your setup -To enable coverage you need to: +To enable coverage, you need to: * Adjust your build process so that JaCoCo report generation step runs _before_ the SonarScanner step. * Make sure that JacCoCo writes its report file to a defined path in the build environment. @@ -102,7 +101,7 @@ See [Coverage Analysis Parameters](/analysis/test-coverage/test-coverage-paramet The path can be either absolute or relative to the project root. -## **Add coverage in a multi-module Maven project** +## Add coverage in a multi-module Maven project For multi-module Maven projects, you configure the `jacoco-maven-plugin` in a profile in the parent pom just as in the single module case, above. By default, a separate coverage report will be generated for each module. diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/javascript-typescript-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/javascript-typescript-test-coverage.md index 4024800383e..bb7031b8a87 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/javascript-typescript-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/javascript-typescript-test-coverage.md @@ -5,10 +5,9 @@ url: /analysis/test-coverage/javascript-typescript-test-coverage/ SonarQube supports the reporting of test coverage information as part of the analysis of your JS/TS project. -However, SonarQube does not compile the coverage report itself. -Instead, you must set up a third-party tool to produce the coverage report as part of your build process (before the analysis step). -Later, during the analysis steps, the scanner picks up this report and sends it to SonarQube. -The coverage is then displayed on your SonarQube project dashboard, along with the other analysis metrics. +However, SonarQube does not generate the coverage report itself. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. For JS/TS projects, SonarQube directly supports all coverage tools that produce reports in the LCOV format. Additionally, a generic coverage format is also supported if you wish to use an unsupported tool (though you will have to convert its output to the generic format yourself). @@ -19,7 +18,7 @@ For information on the generic format, see Generic Test Data. ## Adjusting your setup -To enable coverage you need to: +To enable coverage, you need to: * Adjust your build process so that the coverage tool runs before the scanner step. * Make sure that the coverage tool writes its report file to a defined path in the build environment. diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/php-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/php-test-coverage.md index 5f370fce3ca..751fa8e2fa4 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/php-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/php-test-coverage.md @@ -5,17 +5,16 @@ url: /analysis/test-coverage/php-test-coverage/ SonarQube supports the reporting of test coverage information as part of the analysis of your PHP project. -However, SonarQube does not compile the coverage report itself. -Instead, you must use a third-party tool to produce the coverage report as part of your build process (before the analysis step). -Later, during the analysis step, the scanner picks up this report and sends it to SonarQube. -The coverage is then displayed on your SonarQube project dashboard along with the other analysis metrics. +However, SonarQube does not generate the coverage report itself. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. For PHP projects, we recommend PHPUnit for testing and coverage reporting. ## Adjust your setup -To enable coverage you need to: +To enable coverage, you need to: * Adjust your build process so that the coverage tool runs _before_ the scanner report generation step runs. * Make sure that the coverage tool writes its report file to a defined path in the build environment. @@ -51,7 +50,7 @@ Simply add the following to your `.github/workflows/build.yml` file: run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml ``` -The resulting file should look something like this: +The resulting file should look something like this: ``` name: build diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/python-test-coverage.md b/server/sonar-docs/src/pages/analysis/test-coverage/python-test-coverage.md index a5044e8267f..012d91e77f2 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/python-test-coverage.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/python-test-coverage.md @@ -5,12 +5,14 @@ url: /analysis/test-coverage/python-test-coverage/ SonarQube supports the reporting of test coverage information as part of the analysis of your Python project. -However, SonarQube does not compile the coverage report itself. Instead, you must use a third-party tool to produce the coverage report as part of your build process (before the analysis step). Later, during the analysis step, the scanner picks up this report and sends it to SonarQube. The coverage is then displayed on your SonarQube project dashboard along with the other analysis metrics. +However, SonarQube does not generate the coverage report itself. +Instead, you must set up a third-party tool to produce the report as part of your build process. +You then need to configure your analysis to tell the SonarScanner where the report is located so that it can pick it up and send it to SonarQube, where it will be displayed on your project dashboard along with the other analysis metrics. ## Adjust your setup -To enable coverage you need to: +To enable coverage, you need to: * Adjust your build process so that the coverage tool runs _before_ the scanner report generation step runs. * Make sure that the coverage tool writes its report file to a defined path in the build environment. @@ -70,11 +72,6 @@ Note that we specify `relative_files = True` in the `tox.ini` file to ensure tha The following shows how to configure the GitHub Actions build file for your Python project so that it works in conjunction with the `tox.ini` configuration file described above to generate code coverage. Your `build.yml` file should look something like this: - - ``` name: Build on: diff --git a/server/sonar-docs/src/pages/analysis/test-coverage/test-coverage-parameters.md b/server/sonar-docs/src/pages/analysis/test-coverage/test-coverage-parameters.md index 90f00b07f61..d5b857dacd6 100644 --- a/server/sonar-docs/src/pages/analysis/test-coverage/test-coverage-parameters.md +++ b/server/sonar-docs/src/pages/analysis/test-coverage/test-coverage-parameters.md @@ -7,8 +7,8 @@ _Test coverage reports_ describe the percentage of your code that has been teste This differs from _test execution reports_, which describe which tests within your test suite have been run during a build. For details, see [Test Execution Parameters](/analysis/test-coverage/test-execution-parameters/). -Test execution reports are not generated by SonarQube itself. -Much like tests coverage reports, test execution reports must be generated by an external tool and then imported into SonarQube by specifying a parameter telling the scanner where to look for the report. +Test coverage reports are not generated by SonarQube itself. +They must be generated by an external tool and then imported into SonarQube by specifying a parameter telling the scanner where to look for the report. The data is then displayed in your SonarQube analysis. Below, you will find language- and tool-specific analysis parameters for importing test coverage reports. -- 2.39.5