Currently maven-surefire-plugin does not allow you to do this. It writes all results to separate files. You can create a request function in problem tracking if you feel that it is a missing function.
However, you can use some Linux commands to convert the output to what you need. Here are a few commands that turn individual XML files into a single file that looks the way you want:
grep testcase target/surefire-reports/TEST-*.xml | sed 's/.* name="\(.*\)" classname="\(.*\)" time="\(.*\)".*/\2#\1() - \3ms/g' | sort -n -k 3 > output.txt
Update : Numerical sorting has problems with varying numbers of fractions of a digit. Use the awk version below to solve this problem.
The same can be done with awk bit shorter and less cryptic:
grep -h testcase target/surefire-reports/TEST-*.xml | awk -F '"' '{printf("%s#%s() - %.3fms\n", $4, $2, $6); }' | sort -n -k 3 > output.txt
You must run these commands from the toplevel directory of your maven project after reporting accuracy.
If you have a multi-module project, use instead:
find . -name TEST-*.xml -exec grep -h testcase {} \; | awk -F '"' '{printf("%s#%s() - %.3fms\n", $4, $2, $6); }' | sort -n -k 3 > output.txt
The resulting file is output.txt and contains lines of the following format:
<classname>#<methodname>() - <time>ms
The result is sorted by time consumed.
source share