标签:ann dll 项目 mat project clu 解压 orm put
一,下载 sonar-scanner-msbuild
我当前下载的最新版本是:sonar-scanner-msbuild-4.5.0.1761-netcoreapp2.0
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild
二,新建dotnetCore 项目 SonarDemo并创建SonarDemo.Tests Project
三,解压sonar-scanner-msbuild-4.5.0.1761-netcoreapp2.0 至我们新建的dotnetCore项目
进入sonar-scanner-netcore 编辑 SonarQube.Analysis.xml 设置SonarQube 地址。
进入sonar-scanner-netcore\sonar-scanner-3.2.0.1227\conf 设置SonarQube 地址。
四,SonarDemo.Tests 项目添加coverlet.msbuild
五,编写单元测试
public class UnitTests { [Fact] public void Test1() { var demoStr = new Demo(); var result= demoStr.stringFormat("test"); Assert.Equal("TEST", result); } }
六,创建SonarScanner.MSBuild.bat
dotnet test SonarDemo.Tests/SonarDemo.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude=\"[xunit.runner.*]*,[SonarDemo.Tests]*\" dotnet sonar-scanner-netcore\SonarScanner.MSBuild.dll begin /k:SonarDemo /n:SonarDemo /v:1.0 /d:sonar.host.url=http://localhost:9000 /d:sonar.login=admin /d:sonar.password=admin /d:sonar.cs.opencover.reportsPaths=SonarDemo.Tests/coverage.opencover.xml /d:sonar.coverage.exclusions=[**Tests*.cs,coverage.opencover.xml] dotnet build dotnet sonar-scanner-netcore\SonarScanner.MSBuild.dll end /d:sonar.login=admin /d:sonar.password=admin
七,编译通过后,双击SonarScanner.MSBuild.bat
DotNetCore + Sonar + Coverlet 代码覆盖率检查
标签:ann dll 项目 mat project clu 解压 orm put
原文地址:https://www.cnblogs.com/mnps/p/10179673.html