SonarQube仪表板中未显示C#测试覆盖率

时间:2019-07-26 11:12:39

标签: c# msbuild sonarqube sonarqube-scan test-coverage

我已经设置了本地 sonarqube ,并正在尝试扫描我的c# (.Net framework 4.7.2)项目。出于某种原因,我发现Sonarqube仪表板上的构建和相关代码指标显示得很好,但是测试覆盖率根本没有显示。它一直显示连字符(-)。

以下是我尝试的步骤:

开始扫描

C:\sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:"TestFrm-07262019" /n:TestFrm-App /v:1.0 /d:sonar.cs.vscoveragexml.reportsPaths="%CD%\testresults\visualstudio.coveragexml" /d:sonar.verbose="true"

构建

msbuild

收集报道

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynamic Code Coverage Tools\amd64\codecoverage.exe" collect /output:VisualStudio.coverage "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" "WebApplication1.Tests\bin\Debug\Microsoft.VisualStudio.TestPlatform.TestFramework.dll"

分析并生成coveragexml

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynamic Code Coverage Tools\amd64\codecoverage.exe" analyze /output:%cd%\testResults\VisualStudio.coveragexml visualstudio.coverage

结束声纳扫描

C:\sonar-scanner-msbuild\SonarScanner.MSBuild.exe end

以上所有命令似乎都可以正常工作,我也看到在输出文件夹中也生成了VisualStudio.coveragexml文件。

在SonarQube仪表板和“项目”页面上,我没有看到任何报道。任何想法,我想念什么?感谢您的帮助。

根据要求,这是扫描结束语句的输出日志:

C:\PoC-Projects\testFramework>C:\sonar-scanner-msbuild\SonarScanner.MSBuild.exe end

                "C:\\PoC-Projects\\testFramework\\ClassLibrary1.Tests\\packages.config"

            CD5B4CBE-0A54-461D-8267-832C64E9E0D3.sonar.cs.roslyn.reportFilePath=C:\\PoC-Projects\\testFramework\\ClassLibrary1.Tests\\bin\\Debug\\ClassLibrary1.Tests.dll.RoslynCA.json
            CD5B4CBE-0A54-461D-8267-832C64E9E0D3.sonar.cs.analyzer.projectOutPath=C:\\PoC-Projects\\testFramework\\.sonarqube\\out\\1
            CD5B4CBE-0A54-461D-8267-832C64E9E0D3.sonar.cs.analyzer.projectOutPaths=\
            "C:\\PoC-Projects\\testFramework\\.sonarqube\\out\\1"
            CD5B4CBE-0A54-461D-8267-832C64E9E0D3.sonar.cs.roslyn.reportFilePaths=\
            "C:\\PoC-Projects\\testFramework\\ClassLibrary1.Tests\\bin\\Debug\\ClassLibrary1.Tests.dll.RoslynCA.json"

            CD5B4CBE-0A54-461D-8267-832C64E9E0D3.sonar.working.directory=C:\\PoC-Projects\\testFramework\\.sonarqube\\out\\.sonar\\mod1
            sonar.cs.vscoveragexml.reportsPaths=C:\\PoC-Projects\\testFramework\\testresults\\visualstudio.coveragexml
            sonar.host.url=http://localhost:9000
            sonar.visualstudio.enable=false

            sonar.modules=EC58A2FF-F147-4765-B425-D4E71D140B43,CD5B4CBE-0A54-461D-8267-832C64E9E0D3


            ------------------------------------------------------------------------
            Writing processing summary to C:\PoC-Projects\testFramework\.sonarqube\out\ProjectInfo.log
            Calling the SonarQube Scanner...
            Executing file C:\sonar-scanner-msbuild\sonar-scanner-3.3.0.1492\bin\sonar-scanner.bat
              Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\PoC-Projects\testFramework\.sonarqube\out\sonar-project.properties --embedded --debug <sensitive data removed>
              Working directory: C:\PoC-Projects\testFramework
              Timeout (ms):-1
              Process id: 44820
            16:09:54.034 INFO: Scanner configuration file: C:\sonar-scanner-msbuild\sonar-scanner-3.3.0.1492\bin\..\conf\sonar-scanner.properties
            16:09:54.038 INFO: Project root configuration file: C:\PoC-Projects\testFramework\.sonarqube\out\sonar-project.properties
            16:09:54.076 INFO: SonarQube Scanner 3.3.0.1492
            16:09:54.076 INFO: Java 12.0.1 Oracle Corporation (64-bit)
            16:09:54.076 INFO: Windows 10 10.0 amd64
            16:09:54.303 DEBUG: keyStore is :
            16:09:54.303 DEBUG: keyStore type is : pkcs12
            16:09:54.303 DEBUG: keyStore provider is :
            16:09:54.304 DEBUG: init keystore
            16:09:54.304 DEBUG: init keymanager of type SunX509
            16:09:55.216 DEBUG: Create: C:\Users\jyoti_k_sinha\.sonar\cache
            16:09:55.218 INFO: User cache: C:\Users\jyoti_k_sinha\.sonar\cache
            16:09:55.218 DEBUG: Create: C:\Users\jyoti_k_sinha\.sonar\cache\_tmp
            16:09:55.221 DEBUG: Extract sonar-scanner-api-batch in temp...
            16:09:55.227 DEBUG: Get bootstrap index...
            16:09:55.228 DEBUG: Download: http://localhost:9000/batch/index
            16:09:55.327 DEBUG: Get bootstrap completed
            16:09:55.332 DEBUG: Create isolated classloader...
            16:09:55.347 DEBUG: Start temp cleaning...
            16:09:55.352 DEBUG: Temp cleaning done
            16:09:55.353 DEBUG: Execution getVersion
            16:09:55.368 INFO: SonarQube server 6.7.7
            16:09:55.369 INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
            16:09:55.370 DEBUG: Work directory: C:\PoC-Projects\testFramework\.sonarqube\out\.sonar
            16:09:55.372 DEBUG: Execution execute
            16:09:56.416 INFO: Publish mode
            16:09:56.572 INFO: Load global settings
            16:09:56.645 DEBUG: GET 200 http://localhost:9000/api/settings/values.protobuf | time=59ms
            16:09:56.665 INFO: Load global settings (done) | time=93ms
            16:09:56.676 INFO: Server id: BF41A1F2-AWuNqJpmLt6gz152AnvP
            16:09:56.688 INFO: User cache: C:\Users\jyoti_k_sinha\.sonar\cache
            16:09:56.976 INFO: Load plugins index
            16:09:56.987 DEBUG: GET 200 http://localhost:9000/api/plugins/installed | time=11ms
            16:09:57.028 INFO: Load plugins index (done) | time=52ms
            16:09:57.028 DEBUG: Load plugins
            16:09:57.083 DEBUG: Load plugins (done) | time=55ms
            16:09:57.191 DEBUG: Plugins:
            16:09:57.192 DEBUG:   * SonarC# 6.5.0.3766 (csharp)
            16:09:57.192 DEBUG:   * SonarPython 1.8.0.1496 (python)
            16:09:57.192 DEBUG:   * SonarJava 4.15.0.12310 (java)
            16:09:57.192 DEBUG:   * Flex 2.3 (flex)
            16:09:57.192 DEBUG:   * SonarQube :: Plugins :: SCM :: Git 1.3.0.869 (scmgit)
            16:09:57.192 DEBUG:   * SonarXML 1.4.3.1027 (xml)
            16:09:57.192 DEBUG:   * SonarPHP 2.11.0.2485 (php)
            16:09:57.192 DEBUG:   * SonarTS 1.1.0.1079 (typescript)
            16:09:57.192 DEBUG:   * SonarQube :: Plugins :: SCM :: SVN 1.6.0.860 (scmsvn)
            16:09:57.192 DEBUG:   * SonarJS 3.2.0.5506 (javascript)
            16:09:57.789 INFO: Process project properties
            16:09:57.802 DEBUG: Process project properties (done) | time=13ms
            16:09:57.843 INFO: Load project repositories
            16:09:57.855 DEBUG: GET 404 http://localhost:9000/batch/project.protobuf?key=TestFrm-07262019 | time=11ms
            16:09:57.856 DEBUG: Project repository not available - continuing without it
            16:09:57.860 INFO: Load project repositories (done) | time=17ms
            16:09:57.933 DEBUG: Available languages:
            16:09:57.933 DEBUG:   * C# => "cs"
            16:09:57.934 DEBUG:   * Python => "py"
            16:09:57.934 DEBUG:   * Java => "java"
            16:09:57.934 DEBUG:   * Flex => "flex"
            16:09:57.934 DEBUG:   * XML => "xml"
            16:09:57.934 DEBUG:   * PHP => "php"
            16:09:57.934 DEBUG:   * TypeScript => "ts"
            16:09:57.934 DEBUG:   * JavaScript => "js"
            16:09:57.947 INFO: Load quality profiles
            16:09:58.653 DEBUG: GET 200 http://localhost:9000/api/qualityprofiles/search.protobuf?defaults=true | time=706ms
            16:09:58.665 INFO: Load quality profiles (done) | time=718ms
            16:09:58.677 INFO: Load active rules
            16:09:58.879 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqPayLt6gz152AoJo&p=1&ps=500 | time=202ms
            16:09:59.095 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqPlULt6gz152AoRI&p=1&ps=500 | time=104ms
            16:09:59.142 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqPySLt6gz152AoWu&p=1&ps=500 | time=30ms
            16:09:59.163 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqPthLt6gz152AoVv&p=1&ps=500 | time=17ms
            16:09:59.197 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqP_-Lt6gz152AocU&p=1&ps=500 | time=33ms
            16:09:59.230 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqQGQLt6gz152AoeT&p=1&ps=500 | time=28ms
            16:09:59.258 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqQV1Lt6gz152AohE&p=1&ps=500 | time=25ms
            16:09:59.282 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWuNqQfLLt6gz152AoiI&p=1&ps=500 | time=23ms
            16:09:59.294 INFO: Load active rules (done) | time=617ms
            16:09:59.296 INFO: Load metrics repository
            16:09:59.307 DEBUG: GET 200 http://localhost:9000/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=11ms
            16:09:59.321 INFO: Load metrics repository (done) | time=25ms
            16:09:59.368 WARN: SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
            16:09:59.369 INFO: Project key: TestFrm-07262019
            16:09:59.369 DEBUG: Start recursive analysis of project modules
            16:09:59.370 INFO: -------------  Scan ClassLibrary1
            16:09:59.538 INFO: Load server rules
            16:09:59.637 DEBUG: GET 200 http://localhost:9000/api/rules/list.protobuf | time=99ms
            16:09:59.648 INFO: Load server rules (done) | time=109ms
            16:09:59.681 INFO: Base dir: C:\PoC-Projects\testFramework\ClassLibrary1
            16:09:59.681 INFO: Working dir: C:\PoC-Projects\testFramework\.sonarqube\out\.sonar\mod0
            16:09:59.683 INFO: Source paths: BankAccount.cs, Properties/AssemblyInfo.cs
            16:09:59.684 INFO: Source encoding: UTF-8, default locale: en_US
            16:09:59.786 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
            16:09:59.787 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
            16:09:59.787 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
            16:09:59.787 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
            16:09:59.787 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
            16:09:59.788 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
            16:09:59.788 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
            16:09:59.788 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
            16:09:59.792 DEBUG: Initializers :
            16:09:59.793 INFO: Index files
            16:09:59.808 INFO: Analyzer working directory contains 5 .pb file(s)
            WARNING: WARNING: An illegal reflective access operation has occurred
            WARNING: WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/C:/Users/jyoti_k_sinha/.sonar/cache/e7d75a48b1b92bcb2e4fba5a10a6f829/sonar-csharp-plugin-6.5.0.3766.jar_unzip/META-INF/lib/protobuf-java-3.1.0.jar) to field java.nio.Buffer.address
            WARNING: WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
            WARNING: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
            WARNING: WARNING: All illegal access operations will be denied in a future release
            16:09:59.856 DEBUG: 'ClassLibrary1/BankAccount.cs' generated metadata  with charset 'UTF-8'
            16:09:59.856 DEBUG: 'ClassLibrary1/Properties/AssemblyInfo.cs' generated metadata  with charset 'UTF-8'
            16:09:59.861 DEBUG: 'Properties\AssemblyInfo.cs' indexed with language 'cs'
            16:09:59.862 DEBUG: 'BankAccount.cs' indexed with language 'cs'
            16:09:59.863 INFO: 2 files indexed
            16:09:59.864 INFO: Quality profile for cs: Sonar way
            16:10:00.772 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
            16:10:00.773 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
            16:10:00.774 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project
            16:10:00.774 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
            16:10:00.775 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
            16:10:00.775 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
            16:10:00.775 DEBUG: 'Flex' skipped because there is no related file in current project
            16:10:00.775 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
            16:10:00.775 DEBUG: 'XML Sensor' skipped because there is no related file in current project
            16:10:00.776 DEBUG: 'PHP sensor' skipped because there is no related file in current project
            16:10:00.776 DEBUG: 'TypeScript Sensor' skipped because there is no related file in current project
            16:10:00.776 DEBUG: 'TypeScript LCOV Coverage Sensor' skipped because there is no related file in current project
            16:10:00.776 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
            16:10:00.791 DEBUG: Sensors : C# -> SonarJavaXmlFileSensor -> Analyzer for "php.ini" files
            16:10:00.792 INFO: Sensor C# [csharp]
            16:10:00.805 INFO: Importing analysis results from C:\PoC-Projects\testFramework\.sonarqube\out\0\output-cs
            16:10:00.873 INFO: Importing Roslyn report
            16:10:00.895 INFO: Sensor C# [csharp] (done) | time=103ms
            16:10:00.895 INFO: Sensor SonarJavaXmlFileSensor [java]
            16:10:00.896 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
            16:10:00.896 INFO: Sensor Analyzer for "php.ini" files [php]
            16:10:00.899 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=3ms
            16:10:00.899 INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
            16:10:00.902 INFO: -------------  Scan ClassLibrary1.Tests
            16:10:00.924 INFO: Base dir: C:\PoC-Projects\testFramework\ClassLibrary1.Tests
            16:10:00.925 INFO: Working dir: C:\PoC-Projects\testFramework\.sonarqube\out\.sonar\mod1
            16:10:00.932 INFO: Test paths: BankAccountTests.cs, Properties/AssemblyInfo.cs, packages.config
            16:10:00.932 INFO: Source encoding: UTF-8, default locale: en_US
            16:10:00.950 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
            16:10:00.950 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
            16:10:00.950 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
            16:10:00.950 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
            16:10:00.951 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
            16:10:00.951 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
            16:10:00.954 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
            16:10:00.954 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
            16:10:00.958 DEBUG: Initializers :
            16:10:00.959 INFO: Index files
            16:10:00.963 INFO: Analyzer working directory contains 5 .pb file(s)
            16:10:00.971 DEBUG: 'ClassLibrary1.Tests/BankAccountTests.cs' generated metadata as test  with charset 'UTF-8'
            16:10:00.971 DEBUG: 'ClassLibrary1.Tests/Properties/AssemblyInfo.cs' generated metadata as test  with charset 'UTF-8'
            16:10:00.972 DEBUG: 'Properties\AssemblyInfo.cs' indexed as test with language 'cs'
            16:10:00.972 DEBUG: 'BankAccountTests.cs' indexed as test with language 'cs'
            16:10:00.972 DEBUG: 'packages.config' indexed as test with language 'null'
            16:10:00.974 INFO: 3 files indexed
            16:10:00.974 INFO: Quality profile for cs: Sonar way
            16:10:01.023 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
            16:10:01.024 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
            16:10:01.024 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project
            16:10:01.024 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
            16:10:01.024 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'Flex' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'XML Sensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'PHP sensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'TypeScript Sensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'TypeScript LCOV Coverage Sensor' skipped because there is no related file in current project
            16:10:01.025 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
            16:10:01.026 DEBUG: Sensors : C# -> SonarJavaXmlFileSensor -> Analyzer for "php.ini" files
            16:10:01.026 INFO: Sensor C# [csharp]
            16:10:01.026 DEBUG: No files to analyze. Skip Sensor.
            16:10:01.026 INFO: Sensor C# [csharp] (done) | time=0ms
            16:10:01.026 INFO: Sensor SonarJavaXmlFileSensor [java]
            16:10:01.026 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
            16:10:01.026 INFO: Sensor Analyzer for "php.ini" files [php]
            16:10:01.027 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=1ms
            16:10:01.027 INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
            16:10:01.027 INFO: -------------  Scan TestFrm-App
            16:10:01.042 INFO: Base dir: C:\PoC-Projects\testFramework
            16:10:01.042 INFO: Working dir: C:\PoC-Projects\testFramework\.sonarqube\out\.sonar
            16:10:01.046 INFO: Source paths: packages/MSTest.TestAdapter.1.3.2/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll, packages/MSTest.TestAdapter.1.3.2/build/_common/Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll, packages/MSTest.TestAdapter.1.3.2/build/_common/Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
            16:10:01.046 INFO: Source encoding: windows-1252, default locale: en_US
            16:10:01.063 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
            16:10:01.063 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
            16:10:01.063 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
            16:10:01.063 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
            16:10:01.063 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
            16:10:01.063 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
            16:10:01.063 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
            16:10:01.064 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
            16:10:01.065 DEBUG: Initializers :
            16:10:01.065 INFO: Index files
            16:10:01.074 DEBUG: 'packages\MSTest.TestAdapter.1.3.2\build\_common\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' indexed with language 'null'
            16:10:01.074 DEBUG: 'packages\MSTest.TestAdapter.1.3.2\build\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll' indexed with language 'null'
            16:10:01.075 DEBUG: 'packages\MSTest.TestAdapter.1.3.2\build\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll' indexed with language 'null'
            16:10:01.075 INFO: 3 files indexed
            16:10:01.118 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
            16:10:01.118 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
            16:10:01.119 DEBUG: 'C#' skipped because there is no related file in current project
            16:10:01.120 DEBUG: 'C# Tests Coverage Report Import' skipped because there is no related file in current project
            16:10:01.120 DEBUG: '[Deprecated] C# Integration Tests Coverage Report Import' skipped because there is no related file in current project
            16:10:01.120 DEBUG: 'C# Unit Test Results Import' skipped because there is no related file in current project
            16:10:01.121 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project
            16:10:01.121 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
            16:10:01.121 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
            16:10:01.122 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
            16:10:01.122 DEBUG: 'Flex' skipped because there is no related file in current project
            16:10:01.122 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
            16:10:01.123 DEBUG: 'XML Sensor' skipped because there is no related file in current project
            16:10:01.123 DEBUG: 'PHP sensor' skipped because there is no related file in current project
            16:10:01.123 DEBUG: 'TypeScript Sensor' skipped because there is no related file in current project
            16:10:01.123 DEBUG: 'TypeScript LCOV Coverage Sensor' skipped because there is no related file in current project
            16:10:01.124 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
            16:10:01.152 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
            16:10:01.153 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
            16:10:01.153 DEBUG: 'Python Squid Sensor' skipped because there is no related file in current project
            16:10:01.153 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
            16:10:01.153 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
            16:10:01.153 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
            16:10:01.154 DEBUG: 'Flex' skipped because there is no related file in current project
            16:10:01.155 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
            16:10:01.155 DEBUG: 'XML Sensor' skipped because there is no related file in current project
            16:10:01.155 DEBUG: 'PHP sensor' skipped because there is no related file in current project
            16:10:01.156 DEBUG: 'TypeScript Sensor' skipped because there is no related file in current project
            16:10:01.156 DEBUG: 'TypeScript LCOV Coverage Sensor' skipped because there is no related file in current project
            16:10:01.156 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
            16:10:01.156 DEBUG: Sensors : SonarJavaXmlFileSensor -> Analyzer for "php.ini" files -> C# Tests Coverage Report Import -> [Deprecated] C# Integration Tests Coverage Report Import -> C# Unit Test Results Import -> Zero Coverage Sensor -> CPD Block Indexer
            16:10:01.156 INFO: Sensor SonarJavaXmlFileSensor [java]
            16:10:01.157 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
            16:10:01.157 INFO: Sensor Analyzer for "php.ini" files [php]
            16:10:01.157 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
            16:10:01.157 INFO: Sensor C# Tests Coverage Report Import [csharp]
            16:10:01.160 INFO: Parsing the Visual Studio coverage XML report C:\PoC-Projects\testFramework\testresults\visualstudio.coveragexml
            16:10:01.230 INFO: Adding this code coverage report to the cache for later reuse: C:\PoC-Projects\testFramework\testresults\visualstudio.coveragexml
            16:10:01.230 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=73ms
            16:10:01.230 INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]
            16:10:01.230 DEBUG: No coverage property. Skip Sensor
            16:10:01.230 INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms
            16:10:01.230 INFO: Sensor C# Unit Test Results Import [csharp]
            16:10:01.231 DEBUG: No unit test results property. Skip Sensor
            16:10:01.231 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=1ms
            16:10:01.231 INFO: Sensor Zero Coverage Sensor
            16:10:01.246 INFO: Sensor Zero Coverage Sensor (done) | time=15ms
            16:10:01.246 INFO: Sensor CPD Block Indexer
            16:10:01.246 DEBUG: org.sonar.scanner.cpd.deprecated.DefaultCpdBlockIndexer is used for cs
            16:10:01.246 DEBUG: No CpdMapping for language cs
            16:10:01.246 INFO: Sensor CPD Block Indexer (done) | time=0ms
            16:10:01.246 INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
            16:10:01.248 INFO: Calculating CPD for 2 files
            16:10:01.251 DEBUG: Detection of duplications for C:/PoC-Projects/testFramework/ClassLibrary1/BankAccount.cs
            16:10:01.262 DEBUG: Detection of duplications for C:/PoC-Projects/testFramework/ClassLibrary1/Properties/AssemblyInfo.cs
            16:10:01.265 INFO: CPD calculation finished
            16:10:01.403 INFO: Analysis report generated in 124ms, dir size=39 KB
            16:10:01.583 INFO: Analysis reports compressed in 179ms, zip size=14 KB
            16:10:01.583 INFO: Analysis report generated in C:\PoC-Projects\testFramework\.sonarqube\out\.sonar\scanner-report
            16:10:01.584 DEBUG: Upload report
            16:10:02.925 DEBUG: POST 200 http://localhost:9000/api/ce/submit?projectKey=TestFrm-07262019&projectName=TestFrm-App | time=1337ms
            16:10:02.929 INFO: Analysis report uploaded in 1345ms
            16:10:02.931 INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/TestFrm-07262019
            16:10:02.931 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
            16:10:02.931 INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWwt3b9cXbfPqESi29yA
            16:10:02.934 DEBUG: Report metadata written to C:\PoC-Projects\testFramework\.sonarqube\out\.sonar\report-task.txt
            16:10:02.937 DEBUG: Post-jobs :
            16:10:02.945 INFO: Task total time: 5.739 s
            16:10:03.040 INFO: 
            16:10:03.040 INFO: EXECUTION SUCCESS
            16:10:03.040 INFO: 
            16:10:03.040 INFO: Total time: 9.048s
            16:10:03.075 INFO: Final Memory: 7M/34M
            16:10:03.075 INFO: 
            Process returned exit code 0
            The SonarQube Scanner has finished
            16:10:03.205  Post-processing succeeded

更新

升级到Sonarscanner-msbuild-4.6Sonarqube 7.9.1之后,我发现Coverage部分出现在Sonarqube的项目仪表板上。我仍然认为覆盖率是0%...我正在调查,希望不久后会更新。

成功更新:哇...现在可以使用。由于某种原因,VSTest似乎出现了问题。我从它们各自的文件夹中删除了以前的visualstudio.coverage和coveragexml文件,然后重新运行coverage,一切都很好... 立即查看Project的Sonar仪表板

enter image description here

1 个答案:

答案 0 :(得分:0)

似乎您使用的是SonarQube的旧版本(6.7 vs 7.9)和声纳扫描仪(3.3 vs 4.0)。我知道较旧的声纳扫描仪中存在一些与无法正确分析有关的错误。

能否更新SonarQube和声纳扫描仪,然后重试。我认为这将为您解决很多问题。

SonarQube download

Sonar Scanner download