Last Updated: February 25, 2016
·
723
· pintolaranja

Swimming through maven failsafe-reports

Either because you prefer to do it or because you cannot rely solely on your ide configuration, in case you run your tests in some console, this may be useful.

The failsafe-reports maven directory that keeps the test execution reports is pretty cluttered. You build your stuff, tests are run, and you cannot follow through the whole console test to see what is going on. It scrolls too fast.

Then, you see that the build broke because some test failed, so you should have a look into a directory called failsafe-reports in the path shown to you in order to figure the actual results. Here is where you will find most of the times dozens of text files. Each will represent one of your junit tests classes, each will most likely have several tests that were run. Which of them failed? Do you really want to dig into each file to figure it out?

I find the example provided here to be a simple way to understand which of the actual tests failed. Go to the maven failsafe-reports directory of your project and do:

find . -name "*.txt" | xargs grep "FAILURE"

That is it. You will get a much smaller list that looks like this:

./somepackage.TestClassNameA.txt:Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 12.335 sec <<< FAILURE!
./somepackage.TestClassNameB.txt:Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.832 sec <<< FAILURE!

And then all you need to do is something like:

less  ./somepackage.TestClassNameA.txt

In order to get your diagnosis information.