Created
January 19, 2018 07:54
-
-
Save stianlagstad/e3b3aaca66209a122159731cbf325100 to your computer and use it in GitHub Desktop.
Using maven and surefire? This script will help you figure out which tests are slow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script goes through tests results in `target/surefire-reports` and sorts the results by the | |
# amount of time they took. This is helpful to identify slow tests. | |
set -e | |
# Make sure the surefire folder exists | |
if [ ! -d "target/surefire-reports" ]; then | |
echo "The folder 'target/surefire-reports' doesn't exists. Please run tests before using this script." | |
exit 1 | |
fi | |
# Go through the surefire test reports and sort tests by time taken. Source for this snippet: | |
# https://stackoverflow.com/questions/45854277/execution-time-of-tests-in-unit-test-class-via-maven-surefire-report-in-a-single/45859700#45859700 | |
grep -h testcase target/surefire-reports/TEST-*.xml | | |
awk -F '"' '{print $4 "#" $2 "() - " $6 "ms" }' | | |
sort -rn -k 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment