File tree Expand file tree Collapse file tree 7 files changed +90
-1
lines changed
main/java/com/microsoft/demo Expand file tree Collapse file tree 7 files changed +90
-1
lines changed Original file line number Diff line number Diff line change 2424
2525# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2626hs_err_pid *
27+
28+ .idea /
29+
30+ * .iml
31+ target /
Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ steps:
1919 testResultsFiles : ' **/TEST-*.xml'
2020 tasks : ' build'
2121
22+ # Publish Cobertura or JaCoCo code coverage results from a build
23+ - task : PublishCodeCoverageResults@1
24+ inputs :
25+ codeCoverageTool : ' JaCoCo'
26+ summaryFileLocation : ' $(System.DefaultWorkingDirectory)/**/reports/code-cov-report.xml'
27+ reportDirectory : ' $(System.DefaultWorkingDirectory)/**/reports/code-cov-report.html'
28+ failIfCoverageEmpty : true
29+
2230- task : CopyFiles@2
2331 inputs :
2432 contents : ' **/helloworld*.jar'
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ steps:
1818 testResultsFiles : ' **/TEST-*.xml'
1919 goals : ' package'
2020
21+ # Publish Cobertura or JaCoCo code coverage results from a build
22+ - task : PublishCodeCoverageResults@1
23+ inputs :
24+ codeCoverageTool : ' JaCoCo'
25+ summaryFileLocation : ' $(System.DefaultWorkingDirectory)/**/site/jacoco/jacoco.xml'
26+ reportDirectory : ' $(System.DefaultWorkingDirectory)/**/site/jacoco'
27+ failIfCoverageEmpty : true
28+
2129- task : CopyFiles@2
2230 inputs :
2331 contents : ' **/*.war'
Original file line number Diff line number Diff line change 11apply plugin : ' java'
22apply plugin : ' maven'
3+ apply plugin : ' jacoco'
34
45group = ' helloworld'
56version = ' 1.0-SNAPSHOT'
@@ -16,3 +17,14 @@ repositories {
1617dependencies {
1718 testCompile group : ' junit' , name : ' junit' , version :' 4.11'
1819}
20+
21+ jacocoTestReport {
22+ reports {
23+ xml. enabled true
24+ xml. destination " ${ buildDir} /reports/code-cov-report.xml"
25+ html. enabled true
26+ html. destination " ${ buildDir} /reports/code-cov-report.html"
27+ }
28+ }
29+
30+ check. dependsOn jacocoTestReport
Original file line number Diff line number Diff line change 1919
2020 <build >
2121 <finalName >helloworld</finalName >
22+
23+ <plugins >
24+ <plugin >
25+ <groupId >org.jacoco</groupId >
26+ <artifactId >jacoco-maven-plugin</artifactId >
27+ <version >0.8.2</version >
28+ <executions >
29+ <execution >
30+ <id >prepare-agent</id >
31+ <goals >
32+ <goal >prepare-agent</goal >
33+ </goals >
34+ </execution >
35+ <execution >
36+ <id >report</id >
37+ <phase >prepare-package</phase >
38+ <goals >
39+ <goal >report</goal >
40+ </goals >
41+ </execution >
42+ <execution >
43+ <id >post-unit-test</id >
44+ <phase >test</phase >
45+ <goals >
46+ <goal >report</goal >
47+ </goals >
48+ <configuration >
49+ <!-- Sets the path to the file which contains the execution data. -->
50+ <dataFile >target/jacoco.exec</dataFile >
51+ <!-- Sets the output directory for the code coverage report. -->
52+ <outputDirectory >target/jacoco-ut</outputDirectory >
53+ </configuration >
54+ </execution >
55+ </executions >
56+ <configuration >
57+ <systemPropertyVariables >
58+ <jacoco-agent .destfile>target/jacoco.exec</jacoco-agent .destfile>
59+ </systemPropertyVariables >
60+ </configuration >
61+ </plugin >
62+ </plugins >
2263 </build >
2364
2465 <properties >
Original file line number Diff line number Diff line change 1+ package com .microsoft .demo ;
2+
3+ public class Demo {
4+ public void DoSomething (boolean flag ){
5+ if (flag ){
6+ System .out .println ("I am covered" );
7+ return ;
8+ }
9+
10+ System .out .println ("I am not covered" );
11+ }
12+ }
Original file line number Diff line number Diff line change 1- import org .junit .*;
1+ import com .microsoft .demo .Demo ;
2+ import org .junit .Test ;
23
34public class MyTest {
45 @ Test
56 public void test_method_1 () {
7+ Demo d = new Demo ();
8+ d .DoSomething (true );
69 }
710
811 @ Test
You can’t perform that action at this time.
0 commit comments