2014-10-06 91 views
0

我想獲得C#單元測試覆蓋率。
下面是我的聲納設置,但是當我運行聲納亞軍我沒有看到任何與 聯合測試覆蓋範圍和結果在瀏覽器上的任何事情,它不顯示任何單元測試 覆蓋。
我的問題是:聲納c#plugin頁面說,gallio是作爲它的一部分安裝的。我假設我不需要在外部安裝gallio,但是當我運行聲納亞軍時,它會調用gallio,然後調用opencover來獲得覆蓋範圍?
我在做什麼錯?sonarqube與gallio openCover - 如何?

# Required metadata 

sonar.projectKey=MyProg  
sonar.projectName=MyProg 

sonar.projectVersion=1.0 

# sonar.sources=C:/MyProj 
sonar.sources=. 
sonar.language=cs 

# Encoding of the source code 

sonar.sourceEncoding=UTF-8 



# Additional parameters 

# sonar.my.property=value 





#Core C# Settings 
sonar.dotnet.visualstudio.solution.file=AS.sln 
sonar.dotnet.excludeGeneratedCode=true 
sonar.dotnet.4.0.sdk.directory=C:/Windows/Microsoft.NET/Framework/v4.0.30319 
sonar.dotnet.version=4.0 



#Gendarme 
sonar.gendarme.mode= 

# Gallio/Unit Tests 
sonar.gallio.mode= 
sonar.gallio.coverage.tool=OpenCover 
sonar.gallio.runner=IsolatedProcess 
sonar.dotnet.visualstudio.testProjectPattern=*Test* 
sonar.opencover.installDirectory=C:/opencover.4.5.2506/ 

# FXCop 
sonar.fxcop.mode=skip 

# StyleCop 
sonar.stylecop.mode=skip 

# NDeps 
sonar.ndeps.mode=skip 

我沒有找到有關加利奧在聲納記錄任何信息:

所有的
c:\Program Files\sonar-runner-dist-2.4\sonar-runner-2.4\bin\.. 
SonarQube Runner 2.4 
Java 1.7.0_40 Oracle Corporation (64-bit) 
Windows 7 6.1 amd64 
INFO: Error stacktraces are turned on. 
INFO: Runner configuration file: c:\Program Files\sonar-runner-dist-2.4\sonar-runner-2.4\bin\..\conf\sonar-runner.properties 
INFO: Project configuration file: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\sonar-project.properties 
INFO: Default locale: "en_US", source code encoding: "UTF-8" 
INFO: Work directory: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\.\.sonar 
INFO: SonarQube Server 4.5 
18:30:31.202 INFO - Load global referentials... 
18:30:31.309 INFO - Load global referentials done: 109 ms 
18:30:31.316 INFO - User cache: C:\Users\vikas.c\.sonar\cache 
18:30:31.323 INFO - Install plugins 
18:30:31.433 INFO - Install JDBC driver 
18:30:31.438 INFO - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 
18:30:32.494 INFO - Initializing Hibernate 
18:30:33.577 INFO - Load project referentials... 
18:30:33.829 INFO - Load project referentials done: 253 ms 
18:30:33.829 INFO - Load project settings 
18:30:34.207 INFO - Loading technical debt model... 
18:30:34.234 INFO - Loading technical debt model done: 27 ms 
18:30:34.236 INFO - Apply project exclusions 
18:30:34.438 INFO - ------------- Scan Sage AS 
18:30:34.442 INFO - Load module settings 
18:30:34.603 INFO - Language is forced to cs 
18:30:34.603 INFO - Loading rules... 
18:30:35.074 INFO - Loading rules done: 471 ms 
18:30:35.091 INFO - Configure Maven plugins 
18:30:35.147 INFO - Compare to previous analysis (2014-10-06) 
18:30:35.153 INFO - Compare over 30 days (2014-09-06, analysis of 2014-10-06 13:42:43.0) 
18:30:35.154 INFO - No quality gate is configured. 
18:30:35.267 INFO - Base dir: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\. 
18:30:35.267 INFO - Working dir: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\.\.sonar 
18:30:35.268 INFO - Source paths: . 
18:30:35.268 INFO - Source encoding: UTF-8, default locale: en_US 
18:30:35.268 INFO - Index files 
18:30:35.599 INFO - 132 files indexed 
18:30:46.573 INFO - Quality profile for cs: Sonar way 
18:30:46.696 INFO - All FxCop rules are disabled, skipping its execution. 
18:30:46.699 INFO - Sensor QProfileSensor... 
18:30:46.704 INFO - Sensor QProfileSensor done: 5 ms 
18:30:46.704 INFO - Sensor InitialOpenIssuesSensor... 
18:30:46.729 INFO - Sensor InitialOpenIssuesSensor done: 25 ms 
18:30:46.729 INFO - Sensor ProjectLinksSensor... 
18:30:46.733 INFO - Sensor ProjectLinksSensor done: 4 ms 
18:30:46.734 INFO - Sensor VersionEventsSensor... 
18:30:46.856 INFO - Sensor VersionEventsSensor done: 122 ms 
18:30:46.856 INFO - Sensor FileHashSensor... 
18:30:46.878 INFO - Sensor FileHashSensor done: 22 ms 
18:30:46.878 INFO - Sensor [email protected] 
18:30:46.925 INFO - 132 source files to be analyzed 
18:30:47.818 INFO - 132/132 source files analyzed 
18:30:48.015 INFO - Sensor [email protected] done: 1137 ms 
18:30:48.015 INFO - Sensor CPD Sensor (wrapped)... 
18:30:48.015 INFO - DefaultCpdEngine is used for cs 
18:30:48.021 INFO - Cross-project analysis disabled 
18:30:48.601 INFO - Sensor CPD Sensor (wrapped) done: 586 ms 
18:30:48.830 INFO - Execute decorators... 
18:30:50.537 INFO - Store results in database 
18:30:53.723 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/SageCNAAS 
18:30:53.779 INFO - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob 
18:30:53.781 INFO - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob 
18:30:53.823 INFO - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob 
18:30:53.838 INFO - -> Keep one snapshot per day between 2014-09-08 and 2014-10-05 
18:30:53.839 INFO - -> Keep one snapshot per week between 2013-10-07 and 2014-09-08 
18:30:53.840 INFO - -> Keep one snapshot per month between 2009-10-12 and 2013-10-07 
18:30:53.841 INFO - -> Delete data prior to: 2009-10-12 
18:30:53.849 INFO - -> Clean Sage AS [id=1] 
18:30:53.854 INFO - <- Clean snapshot 1850 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION SUCCESS 
INFO: ------------------------------------------------------------------------ 
Total time: 23.752s 
Final Memory: 16M/675M 
INFO: ------------------------------------------------------------------------ 
+0

這可能是相關的http://stackoverflow.com/questions/12813431/sonar-with-gallio-and-opencover-code-coverage-0?rq= 1 – 2014-10-06 21:17:24

回答

2

首先,你必須定義測試項目的模式。 sonar/opencover無法識別您的測試二進制文件。其次,如果您使用的是聲納4.3以上,您可能想知道聲納已經結束了對gallio和opencover的支持。在這種情況下,您需要從外部導入coverage xml以獲得覆蓋。請使用關於聲納版本的適當信息來增強您的帖子等。

+0

爲什麼他們停止支持Gallio和OpenCover? – 2014-10-12 22:35:18

+0

謝謝@cypher,我的聲納版本是4.5。你能解釋一下「從外部輸入coverage xml」是什麼意思嗎? 請詳細解釋,以便我可以按照這些步驟生成單元測試覆蓋率報告。我的基本要求是我需要爲sonarqube中的C#項目生成單元測試覆蓋率報告。 – vikas 2014-10-14 06:43:47

+0

看,這將解決你的問題。 http://kavishsomani.wordpress.com/ – Cypher 2014-10-14 10:45:33