|
7 | 7 |
|
8 | 8 | <groupId>com.example</groupId> |
9 | 9 | <artifactId>java-maven-junit-helloworld</artifactId> |
10 | | - <version>1.0-SNAPSHOT</version> |
| 10 | + <version>2.0-SNAPSHOT</version> |
11 | 11 | <packaging>jar</packaging> |
12 | 12 |
|
13 | 13 | <properties> |
14 | 14 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
15 | 15 | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| 16 | + |
| 17 | + <!-- This configures the compiler to produce Java 8 class files. --> |
| 18 | + <!-- The minimum JDK version installed is 8 of course, but newer JDK releases should work too. --> |
| 19 | + <maven.compiler.source>1.8</maven.compiler.source> |
| 20 | + <maven.compiler.target>${maven.compiler.source}</maven.compiler.target> |
| 21 | + |
| 22 | + <junit.jupiter.version>5.2.0</junit.jupiter.version> |
| 23 | + <junit.platform.version>1.2.0</junit.platform.version> |
| 24 | + <hamcrest.version>1.3</hamcrest.version> |
| 25 | + <mockito.version>2.21.0</mockito.version> |
| 26 | + <jacoco.plugin.version>0.8.1</jacoco.plugin.version> |
16 | 27 | </properties> |
17 | 28 |
|
18 | 29 | <dependencies> |
19 | 30 | <!-- Testing dependencies. --> |
20 | 31 | <dependency> |
21 | | - <groupId>junit</groupId> |
22 | | - <artifactId>junit</artifactId> |
23 | | - <version>4.11</version> |
| 32 | + <groupId>org.junit.jupiter</groupId> |
| 33 | + <artifactId>junit-jupiter-api</artifactId> |
| 34 | + <version>${junit.jupiter.version}</version> |
24 | 35 | <scope>test</scope> |
25 | 36 | </dependency> |
26 | 37 | <dependency> |
27 | | - <groupId>org.powermock</groupId> |
28 | | - <artifactId>powermock-module-junit4</artifactId> |
29 | | - <version>1.5.1</version> |
| 38 | + <groupId>org.junit.jupiter</groupId> |
| 39 | + <artifactId>junit-jupiter-params</artifactId> |
| 40 | + <version>${junit.jupiter.version}</version> |
30 | 41 | <scope>test</scope> |
31 | 42 | </dependency> |
32 | 43 | <dependency> |
33 | | - <groupId>org.powermock</groupId> |
34 | | - <artifactId>powermock-api-mockito</artifactId> |
35 | | - <version>1.5.1</version> |
| 44 | + <groupId>org.junit.jupiter</groupId> |
| 45 | + <artifactId>junit-jupiter-engine</artifactId> |
| 46 | + <version>${junit.jupiter.version}</version> |
36 | 47 | <scope>test</scope> |
37 | 48 | </dependency> |
38 | 49 | <dependency> |
39 | | - <groupId>com.github.stefanbirkner</groupId> |
40 | | - <artifactId>system-rules</artifactId> |
41 | | - <version>1.4.0</version> |
42 | | - <scope>test</scope> |
43 | | - <!-- junit:junit-dep is deprecated, and junit:junit replaces it. --> |
44 | | - <exclusions> |
45 | | - <exclusion> |
46 | | - <groupId>junit</groupId> |
47 | | - <artifactId>junit-dep</artifactId> |
48 | | - </exclusion> |
49 | | - </exclusions> |
| 50 | + <groupId>org.hamcrest</groupId> |
| 51 | + <artifactId>hamcrest-core</artifactId> |
| 52 | + <version>${hamcrest.version}</version> |
| 53 | + </dependency> |
| 54 | + <dependency> |
| 55 | + <groupId>org.mockito</groupId> |
| 56 | + <artifactId>mockito-junit-jupiter</artifactId> |
| 57 | + <version>${mockito.version}</version> |
50 | 58 | </dependency> |
51 | 59 | </dependencies> |
52 | 60 |
|
53 | 61 | <build> |
54 | 62 | <plugins> |
| 63 | + |
55 | 64 | <plugin> |
56 | 65 | <!-- Configures the compiler. --> |
57 | 66 | <groupId>org.apache.maven.plugins</groupId> |
58 | 67 | <artifactId>maven-compiler-plugin</artifactId> |
59 | | - <version>3.1</version> |
| 68 | + <version>3.8.0</version> |
60 | 69 | <configuration> |
61 | | - <source>1.6</source> |
62 | | - <target>1.6</target> |
63 | 70 | <compilerArgs> |
64 | 71 | <arg>-Xlint</arg> |
65 | 72 | </compilerArgs> |
66 | 73 | </configuration> |
67 | 74 | </plugin> |
| 75 | + |
68 | 76 | <plugin> |
69 | 77 | <!-- Unit tests are run by surefire. --> |
70 | 78 | <!-- Classes under src/test/java called *Test are included automatically. --> |
71 | | - <!-- Integration tests are run during the test phase. --> |
| 79 | + <!-- Unit tests are run during the test phase. --> |
72 | 80 | <groupId>org.apache.maven.plugins</groupId> |
73 | 81 | <artifactId>maven-surefire-plugin</artifactId> |
74 | | - <version>2.16</version> |
| 82 | + <version>2.22.0</version> |
75 | 83 | </plugin> |
76 | 84 | <plugin> |
77 | 85 | <!-- Integration tests are run by failsafe. --> |
78 | 86 | <!-- Classes under src/test/java called *IT are included automatically. --> |
79 | 87 | <!-- Integration tests are run during the verify phase. --> |
80 | 88 | <groupId>org.apache.maven.plugins</groupId> |
81 | 89 | <artifactId>maven-failsafe-plugin</artifactId> |
82 | | - <version>2.16</version> |
| 90 | + <version>2.22.0</version> |
83 | 91 | <executions> |
84 | 92 | <execution> |
85 | 93 | <goals> |
|
89 | 97 | </execution> |
90 | 98 | </executions> |
91 | 99 | </plugin> |
92 | | - </plugins> |
93 | | - </build> |
94 | 100 |
|
95 | | - <reporting> |
96 | | - <plugins> |
97 | 101 | <plugin> |
98 | | - <!-- JUnit code coverage. --> |
99 | | - <groupId>org.codehaus.mojo</groupId> |
100 | | - <artifactId>cobertura-maven-plugin</artifactId> |
101 | | - <version>2.6</version> |
| 102 | + <!-- Code coverage plugin. --> |
| 103 | + <!-- This sets up code coverage for the unit tests, the integration tests, --> |
| 104 | + <!-- and the combined coverage of both. --> |
| 105 | + <!-- After running a `mvn clean install`, open `target/site/jacoco-both/index.html` in a browser. --> |
| 106 | + <groupId>org.jacoco</groupId> |
| 107 | + <artifactId>jacoco-maven-plugin</artifactId> |
| 108 | + <version>${jacoco.plugin.version}</version> |
| 109 | + <executions> |
| 110 | + <execution> |
| 111 | + <id>jacoco-prepare-agent</id> |
| 112 | + <goals> |
| 113 | + <goal>prepare-agent</goal> |
| 114 | + </goals> |
| 115 | + </execution> |
| 116 | + <execution> |
| 117 | + <id>jacoco-prepare-agent-integration</id> |
| 118 | + <goals> |
| 119 | + <goal>prepare-agent-integration</goal> |
| 120 | + </goals> |
| 121 | + </execution> |
| 122 | + <execution> |
| 123 | + <id>jacoco-report</id> |
| 124 | + <goals> |
| 125 | + <goal>report</goal> |
| 126 | + </goals> |
| 127 | + </execution> |
| 128 | + <execution> |
| 129 | + <id>jacoco-check</id> |
| 130 | + <goals> |
| 131 | + <goal>check</goal> |
| 132 | + </goals> |
| 133 | + <configuration> |
| 134 | + <rules /> |
| 135 | + </configuration> |
| 136 | + </execution> |
| 137 | + <execution> |
| 138 | + <!-- Combine the code coverage statistics generated for the unit and the integration tests. --> |
| 139 | + <id>jacoco-merge</id> |
| 140 | + <goals> |
| 141 | + <goal>merge</goal> |
| 142 | + </goals> |
| 143 | + <phase>verify</phase> |
| 144 | + <configuration> |
| 145 | + <fileSets> |
| 146 | + <fileSet> |
| 147 | + <directory>${project.build.directory}</directory> |
| 148 | + <includes> |
| 149 | + <include>*.exec</include> |
| 150 | + </includes> |
| 151 | + </fileSet> |
| 152 | + </fileSets> |
| 153 | + <destFile>${project.build.directory}/jacoco-both.exec</destFile> |
| 154 | + </configuration> |
| 155 | + </execution> |
| 156 | + <execution> |
| 157 | + <id>jacoco-integration</id> |
| 158 | + <goals> |
| 159 | + <goal>report-integration</goal> |
| 160 | + </goals> |
| 161 | + </execution> |
| 162 | + <execution> |
| 163 | + <id>jacoco-reportboth</id> |
| 164 | + <goals> |
| 165 | + <goal>report</goal> |
| 166 | + </goals> |
| 167 | + <configuration> |
| 168 | + <dataFile>${project.build.directory}/jacoco-both.exec</dataFile> |
| 169 | + <outputDirectory>${project.reporting.outputDirectory}/jacoco-both</outputDirectory> |
| 170 | + </configuration> |
| 171 | + </execution> |
| 172 | + </executions> |
102 | 173 | </plugin> |
103 | | - </plugins> |
104 | | - </reporting> |
105 | 174 |
|
| 175 | + </plugins> |
| 176 | + </build> |
106 | 177 | </project> |
0 commit comments