When using e.g. mvn test -Tn
to run Maven builds parallelized n-fold, how can I get Maven to prefix its log output with the identifier of the parallel test runner? Currently the log output looks like:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] -------------------------------------------------------
which makes it very difficult to tell which instance logged what
I would like it to show some kind of parallel execution (thread, process, whatever) identifier in the logs, like:
[1][INFO] -------------------------------------------------------
[1][INFO] T E S T S
[2][INFO] -------------------------------------------------------
[2][INFO] T E S T S
[2][INFO] -------------------------------------------------------
[1][INFO] -------------------------------------------------------
It's easy enough to get thread identifiers in the log output by adding -Dorg.slf4j.simpleLogger.showThreadName=true
to MAVEN_OPTS
envionment variable (as described at https://maven.apache.org/maven-logging.html) but this doesn't seem to affect surefire output, for example:
[BuilderThread 1] [INFO] Surefire report directory: C:\redacted\path\to\module2\target\surefire-reports
[BuilderThread 0] [INFO] Nothing to compile - all classes are up to date
[BuilderThread 0] [INFO]
[BuilderThread 0] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ module1 ---
[BuilderThread 0] [INFO] Surefire report directory: C:\redacted\path\to\module1\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
-------------------------------------------------------
T E S T S
-------------------------------------------------------
First by using -T ...
you don't run the integration tests in parallel you run the building of the modules in parallel.
Furthermore if you are using maven-surefire-plugin you are doing something wrong, cause maven-surefire-plugin is for running unit tests whereas maven-failsafe-plugin is for integration test.
To parallelize the tests itself you should check the docs how to do that.
Apart from that you should use mvn ... verfiy
to be sure that the pre-integration-test
, integration-test
and post-integration-test
phase have run. If you call mvn .. integration-test
the post-integration-test
will not being executed.
Furthermore by definition integration tests can't be parallized cause they usually use resources, are coupled in other ways..only unit tests can be parallized by definition cause they are independent etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With