Use cobertura test coverage tool instead of jacoco in sonar

1. download sonar zip , unzip to $SONAR_HOME folder

2. put below xml into settings.xml of maven

    

<profile>
		<id>sonar</id>
		<activation>
		    <activeByDefault>true</activeByDefault>
		</activation>
		<properties>
		    <!-- optional URL to server. Default value is http://localhost:9000 -->
		    <sonar.host.url>http://localhost:9000/</sonar.host.url>
		</properties>
	</profile>

3. go to maven root path

    mvn clean compile

    mvn sonar:sonar

4. start sonar server

the default test coverage tool is jacoco, but sometimes it doesn't work,

it throw the errors : no JaCoCo execution data has been dumped

we can see 0% test coverage in sonar page.

so we can use cobertura instead of it.

5. download sonar-cobertura-plugin jar here

6. placed this file into $SONAR_HOME/extensions/plugins/ folder

7. go to sonar page:  settings->general setting-> java->

    change "Code coverage plugin" value as "cobertura"

8. restart sonar

9. go to maven project root path:

    mvn clean compile

    mvn sonar:sonar

that's it.

猜你喜欢

转载自sunxboy.iteye.com/blog/2003420
今日推荐