SonarQube报告中包含Blazor组件源文件的0%代码覆盖率

问题描述

我有一个Blazor应用,其中包含许多组件。在Visual Studio上对这些组件进行单元测试会为我提供完整的覆盖率报告。 使用MSBuild Scanner使用SonarQube扫描代码时,我的单元测试命令是:

dotnet test .\Tests\App.Test.csproj /p:CollectCoverage=true /p:CoverletoutputFormat=opencover --logger trx

但是我的SonarQube网络报告中Blazor代码覆盖率仅为0%。

我的扫描仪命令:

 dotnet "C:\Program Files\sonar-scanner\SonarScanner.MSBuild.dll" begin /k:"My-Project" /d:sonar.cs.opencover.reportsPaths="Tests\coverage.opencover.xml"

dotnet build

dotnet "C:\Program Files\sonar-scanner\SonarScanner.MSBuild.dll" end

我想知道我的配置文件SonarQube.Analysis.xml中是否缺少任何项目。

解决方法

不幸的是,SonarQube尚未分析Blazor文件。因此它不会处理您的承保范围报告的结果。