1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >uk.co.compendiumdev</groupId >
8+ <artifactId >junitexamples</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+
11+ <properties >
12+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
13+ <junit .jupiter.version>5.6.2</junit .jupiter.version>
14+ <!-- configure the compiler plugin via properties rather than plugin -->
15+ <!-- https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html -->
16+ <maven .compiler.source>1.9</maven .compiler.source>
17+ <maven .compiler.target>1.9</maven .compiler.target>
18+
19+ <!-- to generate html junit reports for test phase -->
20+ <maven-site-plugin .version>3.7.1</maven-site-plugin .version>
21+ <maven .surefire.report.version>3.0.0-M4</maven .surefire.report.version>
22+
23+ <!-- to create the code coverage report -->
24+ <jacoco-version >0.8.10</jacoco-version >
25+ </properties >
26+
27+
28+ <dependencies >
29+ <!-- adding the api and engine allow JUnit 5 to work -->
30+ <dependency >
31+ <groupId >org.junit.jupiter</groupId >
32+ <artifactId >junit-jupiter-api</artifactId >
33+ <version >${junit.jupiter.version} </version >
34+ <scope >test</scope >
35+ </dependency >
36+ <dependency >
37+ <groupId >org.junit.jupiter</groupId >
38+ <artifactId >junit-jupiter-engine</artifactId >
39+ <version >${junit.jupiter.version} </version >
40+ <scope >test</scope >
41+ </dependency >
42+ </dependencies >
43+
44+ <build >
45+ <plugins >
46+ <!--
47+ Maven Surefire Plugin to run the Unit tests
48+ https://maven.apache.org/surefire/maven-surefire-plugin/usage.html
49+ -->
50+ <plugin >
51+ <groupId >org.apache.maven.plugins</groupId >
52+ <artifactId >maven-surefire-plugin</artifactId >
53+ <version >${maven.surefire.report.version} </version >
54+ </plugin >
55+
56+ <!--
57+ Maven Site Plugin to create the HTML site
58+ https://maven.apache.org/surefire/maven-surefire-plugin/usage.html
59+ -->
60+ <plugin >
61+ <groupId >org.apache.maven.plugins</groupId >
62+ <artifactId >maven-site-plugin</artifactId >
63+ <version >${maven-site-plugin.version} </version >
64+ </plugin >
65+
66+
67+ <!-- add code coverage and make sure it covers both Junit4 and Junit5 -->
68+ <plugin >
69+ <groupId >org.jacoco</groupId >
70+ <artifactId >jacoco-maven-plugin</artifactId >
71+ <version >${jacoco-version} </version >
72+ <!-- defaults to target/jacoco.exec -->
73+ <executions >
74+ <!-- allow Jacoco to run -->
75+ <execution >
76+ <goals >
77+ <goal >prepare-agent</goal >
78+ </goals >
79+ </execution >
80+ <!--
81+ Generate the html report for the test phase
82+ https://www.eclemma.org/jacoco/trunk/doc/report-mojo.html
83+ -->
84+ <execution >
85+ <id >report</id >
86+ <!-- generate coverage report for test phase -->
87+ <!-- target/site/jacoco -->
88+ <phase >test</phase >
89+ <goals >
90+ <goal >report</goal >
91+ </goals >
92+ </execution >
93+ </executions >
94+ </plugin >
95+ </plugins >
96+ </build >
97+
98+ <!-- `mvn clean test site` to generate the junit html report-->
99+ <reporting >
100+ <plugins >
101+ <!--
102+ Maven Reports Plugin to generate the HTML reports
103+ https://maven.apache.org/surefire/maven-surefire-report-plugin/index.html
104+ -->
105+ <plugin >
106+ <groupId >org.apache.maven.plugins</groupId >
107+ <artifactId >maven-surefire-report-plugin</artifactId >
108+ <version >${maven.surefire.report.version} </version >
109+ </plugin >
110+
111+ <!-- generate the coverage report using Jacoco -->
112+ <plugin >
113+ <groupId >org.jacoco</groupId >
114+ <artifactId >jacoco-maven-plugin</artifactId >
115+ <reportSets >
116+ <reportSet >
117+ <reports >
118+ <!-- select non-aggregate reports -->
119+ <report >report</report >
120+ </reports >
121+ </reportSet >
122+ </reportSets >
123+ </plugin >
124+ </plugins >
125+ </reporting >
126+
127+ </project >
0 commit comments