Skip to content

Instantly share code, notes, and snippets.

@ufuk
Last active January 5, 2021 09:48
Show Gist options
  • Save ufuk/8a1b5f64b225e0485285b551e0679676 to your computer and use it in GitHub Desktop.
Save ufuk/8a1b5f64b225e0485285b551e0679676 to your computer and use it in GitHub Desktop.
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