Instantly share code, notes, and snippets.

Embed
What would you like to do?
Lists test classes descending ordered by elapsed time to find out which ones are slower than others. Run this BASH script at project's root.
#!/bin/bash
# Run tests
mvn clean test --fail-never
# Print header
echo
echo "TEST NAME, TESTS COUNT, FAILURES COUNT, ERRORS COUNT, SKIPPED COUNT, TIME ELAPSED"
# Prepare report
filePaths=`find target/surefire-reports -name '*.txt'`
for eachFilePath in ${filePaths}
do
testName=`echo ${eachFilePath} | sed 's/.txt//g' | sed 's/target\/surefire-reports\///g'`
testReport=`cat ${eachFilePath} | grep '^Tests run:.*Time elapsed: ' | sed 's/ sec.*//' | sed 's/, /,/g'`
testReport=${testName}","${testReport}
echo ${testReport}
done | sort --field-separator=',' -k6 -r | sed 's/,/, /g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment