Last active
November 14, 2024 17:32
-
-
Save kthoms/e563b76b317c326ab6cccd7902a64128 to your computer and use it in GitHub Desktop.
Lists directories of Java projects containing JUnit 4 / 5 test cases.
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
#!/usr/bin/env sh | |
function count_junit5_tests () { | |
grep -R --include \*.java "import org.junit.jupiter.api.Test" -m 1 -o -h "$1" | wc -l | |
} | |
function count_junit4_tests () { | |
grep -R --include \*.java "import org.junit.Test" -m 1 -o -h "$1" | wc -l | |
} | |
function marker () { | |
if [ "$1" -eq "0" ]; then | |
echo "✅" | |
else | |
echo "❌" | |
fi | |
} | |
function separator () { | |
printf '=%.0s' {1.."$1"} | |
} | |
printf "| %-9s | %-88s | %-25s | %-25s |\n" "status" "directory" "# JUnit 4 test cases" "# JUnit 5 test cases" | |
printf "| %-9s | %-88s | %-25s | %-25s |\n" $(printf '=%.0s' {1..7}) $(printf '=%.0s' {1..88}) $(printf '=%.0s' {1..25}) $(printf '=%.0s' {1..25}) | |
find . -type d | while read -r dir; do | |
if [[ -d "$dir/src/test/java" ]]; then | |
nr_ju4_tests=$(count_junit4_tests "$dir") | |
nr_ju5_tests=$(count_junit5_tests "$dir") | |
migration_marker=$(marker "$nr_ju4_tests") | |
printf "| %-9s | %-90s | %-25s | %-25s | \n" "$migration_marker" "$dir" "$nr_ju4_tests" "$nr_ju5_tests" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment