Created
May 20, 2013 18:50
-
-
Save johnpbloch/5614379 to your computer and use it in GitHub Desktop.
Run PHPUnit tests by group and report on pass/incomplete/fail by group
This file contains hidden or 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
| function testsbygroup(){ | |
| # Grab a list of groups | |
| groups=`phpunit --list-groups | sed -rn 's/ - (.+)/\1/p'` | |
| if [[ ! $groups ]]; then | |
| return 1 | |
| fi | |
| # Set up some empty arrays | |
| pass=() | |
| incomplete=() | |
| fail=() | |
| for x in $groups; do | |
| # Run the tests, capturing the output | |
| unittestoutput=`phpunit --group $x 2>&1` | |
| # Put the group into the right array based on whether it passed, was incomplete, or failed | |
| # Fallback is to mark the group as failing if we can't verify passing or incomplete | |
| if [[ `echo $unittestoutput | ack 'OK \('` ]]; then | |
| pass=("${pass[@]}" "$x") | |
| elif [[ `echo $unittestoutput | ack 'OK, '` ]]; then | |
| incomplete=("${incomplete[@]}" "$x") | |
| else | |
| fail=("${fail[@]}" "$x") | |
| fi | |
| done | |
| # Display the passing groups | |
| echo -e "\e[1;32mPass\e[0m" | |
| for g in ${pass[@]}; do echo $g; done | |
| # Display the incomplete groups | |
| echo -e "\e[1;33mIncomplete\e[0m" | |
| for g in ${incomplete[@]}; do echo $g; done | |
| # Display the failing groups | |
| echo -e "\e[1;31mFail\e[0m" | |
| for g in ${fail[@]}; do echo $g; done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment