With a view to managing / reducing our build times, I want to identify which unit tests are taking the most time - in a parallel test environment using the maven-suref
Adding to the Maven Surefire Plugin configuration the reportFormat entry and setting its value to plain
(instead of the default brief
) would give you elapsed time per method.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<argLine>-Xmx2G -XX:MaxPermSize=1G -XX:-UseSplitVerifier</argLine>
<failIfNoTests>false</failIfNoTests>
<parallel>classesAndMethods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<reportFormat>plain</reportFormat>
</configuration>
</plugin>
</plugins>
</build>
Output with default reportFormat (brief
):
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.sample.mocking.InternalServiceTestCase
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.241 sec - in com.sample.mocking.InternalServiceTestCase
Output with plain
value:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.sample.mocking.InternalServiceTestCase
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.187 sec - in com.sample.mocking.InternalServiceTestCase
test(com.sample.mocking.InternalServiceTestCase) Time elapsed: 0.005 sec
mockTest(com.sample.mocking.InternalServiceTestCase) Time elapsed: 0.17 sec
mockTestFailureTollerance(com.sample.mocking.InternalServiceTestCase) Time elapsed: 0.007 sec
mockProcessfile(com.sample.mocking.InternalServiceTestCase) Time elapsed: 0.003 sec
This option may give you further details on tests and execution time.