Improve test coverage.

This commit is contained in:
James Cole
2018-03-03 10:15:39 +01:00
parent 9475fef8f6
commit 99d116f4ce
5 changed files with 187 additions and 16 deletions

27
test.sh
View File

@@ -17,11 +17,14 @@ featuretestclass=''
unitflag=''
unittestclass=''
apiflag=''
apitestclass=''
verbalflag=''
testsuite=''
configfile='phpunit.xml';
while getopts 'vcrtf:u:s:' flag; do
while getopts 'vcrtfa:u:s:' flag; do
case "${flag}" in
r)
resetTestFlag='true'
@@ -47,6 +50,11 @@ while getopts 'vcrtf:u:s:' flag; do
unittestclass=./tests/Unit/$OPTARG
echo "Will only run Unit test $OPTARG"
;;
a)
apiflag='true'
apitestclass=./tests/Api/$OPTARG
echo "Will only run Api test $OPTARG"
;;
s)
testsuite="--testsuite $OPTARG"
echo "Will only run test suite '$OPTARG'"
@@ -55,13 +63,12 @@ while getopts 'vcrtf:u:s:' flag; do
esac
done
if [[ $coverageflag == "true" && ($featureflag == "true" || $unitflag == "true") ]]
if [[ $coverageflag == "true" && ($featureflag == "true" || $unitflag == "true" || $apiflag == "true") ]]
then
echo "Use config file specific.xml"
configfile='phpunit.coverage.specific.xml'
fi
# backup current config (if it exists):
if [ -f $ORIGINALENV ]; then
mv $ORIGINALENV $BACKUPENV
@@ -110,10 +117,10 @@ cp $DATABASECOPY $DATABASE
echo "clear caches and what-not.."
php artisan cache:clear
php artisan config:clear
php artisan route:clear
# php artisan config:clear
# php artisan route:clear
# php artisan twig:clean
php artisan view:clear
# php artisan view:clear
# run PHPUnit
if [[ $testflag == "" ]]
@@ -125,16 +132,14 @@ else
if [[ $coverageflag == "" ]]
then
echo "Must run PHPUnit without coverage:"
echo "./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $testsuite"
./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $testsuite
else
echo "Must run PHPUnit with coverage"
echo "./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $testsuite"
./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $testsuite
fi
fi
echo "./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $apitestclass $testsuite"
./vendor/bin/phpunit $verbalflag --configuration $configfile $featuretestclass $unittestclass $apitestclass $testsuite
# restore current config:
if [ -f $BACKUPENV ]; then
mv $BACKUPENV $ORIGINALENV