Skip to content

Commit 2e55643

Browse files
authored
Configure maven-surefire-plugin to attach mockito agent during tests (#892)
* configure maven-surefire-plugin to attach mockito agent during test execution * define maven argLine property for surefire config, because this property does not exist yet. (We could also remove the @{argLine} instead, but the current approach is more informative, indicating that there may be additional arguments.)
1 parent fbb6602 commit 2e55643

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<checkstyle.version>13.3.0</checkstyle.version>
7171
<spring-javaformat-checkstyle.version>0.0.47</spring-javaformat-checkstyle.version>
7272
<spotbugs-maven-plugin.version>4.9.8.2</spotbugs-maven-plugin.version>
73+
74+
<!-- required for mockito to function properly (#890) -->
75+
<argLine/>
76+
7377
</properties>
7478

7579
<dependencyManagement>
@@ -396,6 +400,19 @@
396400
<commitIdGenerationMode>full</commitIdGenerationMode>
397401
</configuration>
398402
</plugin>
403+
<plugin>
404+
<!-- required for mockito to function properly (#890) -->
405+
<!-- https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#mockito-instrumentation -->
406+
<groupId>org.apache.maven.plugins</groupId>
407+
<artifactId>maven-dependency-plugin</artifactId>
408+
<executions>
409+
<execution>
410+
<goals>
411+
<goal>properties</goal>
412+
</goals>
413+
</execution>
414+
</executions>
415+
</plugin>
399416
<plugin>
400417
<groupId>org.apache.maven.plugins</groupId>
401418
<artifactId>maven-surefire-plugin</artifactId>
@@ -409,6 +426,9 @@
409426
<exclude>**/Common.java</exclude>
410427
<exclude>**/common/*.java</exclude>
411428
</excludes>
429+
<!-- required for mockito to function properly (#890) -->
430+
<!--suppress UnresolvedMavenProperty -->
431+
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
412432
</configuration>
413433
</plugin>
414434
</plugins>

0 commit comments

Comments
 (0)