Search code examples
mavenunit-testingjunitmaven-surefire-plugin

Just-in-time mvn test results in addition to final summary


When running the mvn test command against a set of tests, maven executes all of them, prints tracing(which can be parsed in run-time by other party), aggregates the results, and summarizes them "at the end".

Is there a way, via the command line, to get the result for a test by test during the execution? and still have the aggregated summary at the end? Why we have to wait until it completes?

Our Continuous Integration environment can be adapted to get "just-in-time" test(s) feedback, instead of waiting until the whole suite is done to know if some test(s) failed or not. This will save time significantly, so developers could investigate in the failing tests until the suite execution is complete.

On the contrast, when run in Eclipse, we can get just-in-time test results, but it is challenging to integrate that in our environment. Any ideas how to achieve the same through the command line?


Solution

  • During Surefire's execution, for each test executed, you'd see a line like this:

    [INFO] Running com.example.MyTest
    [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in com.example.MyTest
    

    You could catch those that have Failures or Errors larger than 0, and use them to alert developers to the issue.