概念

https://blog.ndepend.com/guide-code-coverage-tools/

Code Coverage Results Import (C#, VB.NET)

Unit Test Execution Results Import (C#, VB.NET)

Prerequisites

http://www.cnblogs.com/chucklu/p/8392259.html

Steps

step1

Begin the SonarQube Analysis and provide all required properties, including "sonar.cs.opencover.reportsPaths" and  "sonar.cs.nunit.reportsPaths"

When  you want to analysis a project by MSBuild.SonarQube.Runner.exe begin, you can pass the following parameters to scanner:

MSBuild.SonarQube.Runner.exe begin /k:"sonarqube_project_key" /n:"sonarqube_project_name" /v:"sonarqube_project_version" /d:sonar.cs.nunit.reportsPaths=".\NUnitResults.xml" /d:sonar.cs.opencover.reportsPaths=".\opencover.xml"

step2

Build the project, for example:

msbuild

step3

Run Unit Tests and Save Results in file "NUnitResults.xml"  

Run Unit Tests & Collect Code Coverage

%NUnit3Console% --inprocess --config:Release --result=NUnitResults.xml "UnitTest.sln"

%OpenCover% -output:".\opencover.xml" -register:user -target:%VSTestConsole% -targetargs:"/TestAdapterPath:%NUnit3TestAdapter% CodeCoverage.UnitTest\bin\Release\CodeCoverage.UnitTest.dll"

step4

End the SonarQube Analysis and upload it to the SonarQube server

MSBuild.SonarQube.Runner.exe end

问题解决:

如果上面的执行出现问题的话,可以查看项目文件夹下的.sonarqube\out\sonar-project.properties,确保配置正确

sonar.cs.nunit.reportsPaths=.\\NUnitResults.xml
sonar.cs.opencover.reportsPaths=.\\opencover.xml

Code Coverage and Unit Test in SonarQube的更多相关文章

  1. 使用Visual Studio Code Coverage和nunit上传单元测试覆盖率和单元测试结果到SonarQube上

    SonarQube.Scanner.MSBuild.exe begin /k:"OMDCCQuotes" /d:sonar.host.url="http://myip:9 ...

  2. 10 Code Coverage Tools for C & C++

    Code coverage is a measure used in software testing that describes the degree to which the source co ...

  3. Gumshoe - Microsoft Code Coverage Test Toolset

    Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...

  4. [Webpack 2] Add Code Coverage to tests in a Webpack project

    How much of your code runs during unit testing is an extremely valuable metric to track. Utilizing c ...

  5. iOS 9 学习系列: Xcode Code Coverage

    Code coverage 是一个计算你的单元測试覆盖率的工具. 高水平的覆盖给你的单元測试带来信心.也表明你的应用被彻底的測试过了. 你可能写了几千个单元測试,但假设覆盖率不高.那么你写的这套測试可 ...

  6. [Jest] Track project code coverage with Jest

    Jest comes pre-packaged with the ability to track code coverage for the modules you're testing, but ...

  7. Effective Java提升Code Coverage代码涵盖率 - 就是爱Java

    虽然我们已经有了测试程序,但是如何得知是否已完整测试了主程序?,透过Code Coverage代码涵盖率,我们可以快速地得知,目前系统中,有多少程序中被测试过,不考虑成本跟投资效益比,涵盖率越高,代表 ...

  8. CI集成phpunit Error: No code coverage driver is available 的解决

    CI集成phpunit时,运行报No code coverage driver is available的错误,如下图: yanglingdeMacBook-Pro:tests yangling$ p ...

  9. 代码覆盖率 (Code Coverage)从简到繁 (一)

    代码覆盖率(Code Coverage)是反映测试用例对被测软件覆盖程度的重要指标,也是衡量测试工作进展情况的重要指标.它也是对测试工作进行量化的重要指标之一,测试工作往往不如开发那样激动人心,一个重 ...

随机推荐

  1. 简单ajax库

    function TuziAjax(reqType,url,fnoK, fnFail) { var xmlHttp = null; if (window.XMLHttpRequest) { xmlHt ...

  2. Android Studio Library 编译成 jar,aar

    1. 导入Library ,打开Library 的build gradle  在最外面添加如下: /** AVLView 自定义的jar 包名 **/ task clearJar(type: Dele ...

  3. Android点击跳转到淘宝的某一商品详情页或者某一店铺页面

    最近项目的有个需求是点击购买资料按钮进入淘宝界面,简单分析一下,如果用户手机有淘宝就打开淘宝的页面,没有的话也可以选择使用webView进行展示,还是使用手机浏览器进行展示. 判断有无淘宝的代码就不贴 ...

  4. 怪异的Ubuntu

    怪异的Ubuntu 简单记录ubuntu上出现并且网上不好找到甚至压根找不到解决方案的疑难杂症. lvextend扩展逻辑卷的容量不能被系统检测到 问题发生在Ubuntu 16.04系统上. 逻辑卷/ ...

  5. 【Oracle】进入sqlplus 删除键backspace时出现^H

    当oracle进入sqlplus后,输入命令时候出现错误,我们按平时的习惯使用backspace键删除错误信息,此时会出现^H 解决办法:进入sqlplus之前,使用stty erase '^H'命令 ...

  6. JavaOO知识点小结一

    Java语言的特点是什么?简单 面向对象 跨平台 多线程 健壮性安全性 垃圾回收机制如何编译和执行java文件?产生帮助文档用什么命令?编译: javac 文件名执行: java 类名产生帮助文档 j ...

  7. WebGL画点程序v1

    本文程序实现画一个点的任务,如下图.其中,点的位置直接给定("硬编码")在顶点着色器中. 整个程序包含两个文件,分别是: 1. HelloPoint1.html <!DOCT ...

  8. Pytorch基础(6)----参数初始化

    一.使用Numpy初始化:[直接对Tensor操作] 对Sequential模型的参数进行修改: import numpy as np import torch from torch import n ...

  9. eas之日期控件

    日期选择框能进行日期和时间的编辑,默认情况下只能进行日期选择“××××年××月××日”,可通过调用用函数setTimeEnabled(boolean)来设置是否也有时间编辑.对日期进行编辑时,可手工直 ...

  10. C#第四节课

    分值语句(1) using System;using System.Collections.Generic;using System.Linq;using System.Text;using Syst ...