Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Sonar
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="icon=false|title=Table of Contents" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86aWNvbj1mYWxzZXx0aXRsZT1UYWJsZSBvZiBDb250ZW50c30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p><img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvY30&locale=en_GB&version=2" data-macro-name="toc"></p></td></tr></table><h1>Code Coverage by Integration Tests</h1><p>To get the code coverage by integration tests on your project, you should simply follow the 5 steps below:</p><ol><li>Attach and configure a JaCoCo agent to the JVM which you will run your integration tests with. To do so, have a look at the detailed JaCoCo documentation to attach the agent: via a <a href="http://www.eclemma.org/jacoco/trunk/doc/agent.html" style="margin-left: 0.0px;">command line</a>, using the <a href="http://www.eclemma.org/jacoco/trunk/doc/maven.html">JaCoCo Maven plugin</a> or using the <a href="http://www.eclemma.org/jacoco/trunk/doc/ant.html" style="margin-left: 0.0px;">JaCoCo Ant task</a>.</li><li>Run your automated or manual integration tests within this JVM. At the end of the execution, JaCoCo will dump the code coverage report in the destination you have set in step 1.</li><li>Configure Sonar to reuse this JaCoCo report. In your project properties file (or directly in the command line), add the <em style="margin-left: 0.0px;">sonar.jacoco.itReportPath</em> property with the path to the JaCoCo IT coverage report as a value.</li><li>Run an analysis to feed Sonar with the information provided by the JaCoCo report.</li><li>Browse the results on the Sonar web interface. On project dashboard, you can add the <em style="margin-left: 0.0px;">Integration test coverage</em> widget:<br /><img class="confluence-embedded-image" confluence-query-params="effects=drop-shadow" src="/download/attachments/230400655/integration-test-widget.png?version=1&modificationDate=1368876868853&effects=drop-shadow" data-image-src="/download/attachments/230400655/integration-test-widget.png?version=1&modificationDate=1368876868853&effects=drop-shadow" data-linked-resource-id="230564909" data-linked-resource-type="attachment" data-linked-resource-default-alias="integration-test-widget.png" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="230400655" title="null > integration-test-widget.png"><br />As usual, drilldown is available from this widget. At file level, you can access detailed code coverage by integration tests on the <em>Coverage</em> tab:<br /><img class="confluence-embedded-image" confluence-query-params="effects=drop-shadow" src="/download/attachments/230400655/coverage-tab.png?version=1&modificationDate=1368876868867&effects=drop-shadow" data-image-src="/download/attachments/230400655/coverage-tab.png?version=1&modificationDate=1368876868867&effects=drop-shadow" data-linked-resource-id="230564910" data-linked-resource-type="attachment" data-linked-resource-default-alias="coverage-tab.png" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="230400655" title="null > coverage-tab.png"></li></ol><p><em>Note</em>: You can still use <a class="confluence-link" href="/display/SONAR/Clover+Plugin" data-linked-resource-id="194314488" data-linked-resource-type="page" data-linked-resource-default-alias="Clover Plugin" data-base-url="http://docs.codehaus.org">Clover</a>, <a class="confluence-link" href="/display/SONAR/Cobertura+Plugin" data-linked-resource-id="230397053" data-linked-resource-type="page" data-linked-resource-default-alias="Cobertura Plugin" data-base-url="http://docs.codehaus.org">Cobertura</a> or <a class="confluence-link" href="/display/SONAR/Emma+Plugin" data-linked-resource-id="116359204" data-linked-resource-type="page" data-linked-resource-default-alias="Emma Plugin" data-base-url="http://docs.codehaus.org">Emma</a> to assess code coverage by unit tests together with <a class="confluence-link" href="/display/SONAR/JaCoCo+Plugin" data-linked-resource-id="230397046" data-linked-resource-type="page" data-linked-resource-default-alias="JaCoCo Plugin" data-base-url="http://docs.codehaus.org">JaCoCo</a> for integration tests.</p><p>Sample projects are available on github that can be <a class="external-link" href="https://github.com/SonarSource/sonar-examples" rel="nofollow">browsed</a> or <a class="external-link" href="https://github.com/SonarSource/sonar-examples/zipball/master" rel="nofollow">downloaded</a>: /projects/code-coverage/it.</p><h1>Combining Code Coverage by Unit and Integration Tests</h1><p>Since Sonar 3.3, Sonar automatically computes the overall code coverage (combination of code coverage by unit tests and integration tests). This feature is enable when both code coverage reports are generated with JaCoCo.</p><p><img class="confluence-embedded-image" confluence-query-params="effects=drop-shadow" src="/download/attachments/230400655/overall_code_coverage.png?version=1&modificationDate=1368876868847&effects=drop-shadow" data-image-src="/download/attachments/230400655/overall_code_coverage.png?version=1&modificationDate=1368876868847&effects=drop-shadow" data-linked-resource-id="230564908" data-linked-resource-type="attachment" data-linked-resource-default-alias="overall_code_coverage.png" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="230400655" title="null > overall_code_coverage.png"></p><table class="wysiwyg-macro" data-macro-name="note" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vdGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body">If coverage by unit tests is not computed with JaCoCo, overall coverage = integration tests coverage.</td></tr></table><p>Sample projects are available on github that can be <a class="external-link" href="https://github.com/SonarSource/sonar-examples" rel="nofollow">browsed</a> or <a class="external-link" href="https://github.com/SonarSource/sonar-examples/zipball/master" rel="nofollow">downloaded</a>:</p><ul><li>/projects/code-coverage/combined ut-it/combined-ut-it-sonar-runner-jacoco</li><li>/projects/code-coverage/combined ut-it/combined-ut-it-multimodule-maven-jacoco</li></ul><p> </p><p>See also the <a href="http://www.sonarsource.org/measure-coverage-by-integration-tests-with-sonar-updated/">Measure Coverage by Integration Tests with Sonar – Updated</a> blog post.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced