Last active
August 29, 2015 14:02
-
-
Save nojimage/58796a9236296824f298 to your computer and use it in GitHub Desktop.
Custom PHPUnit script for CakePHP on NetBaeans 8.0
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 bash | |
## | |
# | |
# Custom PHPUnit script for CakePHP on NetBaeans 8.0 | |
# | |
# @author Takashi Nojima [http://php-tips.com] | |
# @copyright 2014 Takashi Nojima | |
## | |
PROJECT_ROOT=$(cd "$(dirname "$(dirname "$0")")" && pwd) | |
CAKE=app/Console/cake | |
XDEBUG_CONFIG="idekey=netbeans-xdebug" | |
cd "$PROJECT_ROOT" | |
## parse options | |
while [[ $# -gt 2 ]] ; do | |
#echo ">> ${1} ${2}" | |
case $1 in | |
'--colors' ) | |
COLORS=1 | |
;; | |
'--log-junit' ) | |
JUNITLOG="$2" | |
shift | |
;; | |
'--bootstrap' ) | |
BOOTSTRAP="$2" | |
shift | |
;; | |
'--filter' ) | |
FILTER="$2" | |
shift | |
;; | |
'--coverage-clover' ) | |
COVERAGE=$2 | |
shift | |
;; | |
esac | |
shift | |
done | |
SUITE=$1 | |
RUN=$2 | |
RUN=${RUN/--run=/} | |
## debug print | |
#echo "COLORS = $COLORS" | |
#echo "JUNITLOG = $JUNITLOG" | |
#echo "BOOTSTRAP = $BOOTSTRAP" | |
#echo "FILTER = $FILTER" | |
#echo "COVERAGE = $COVERAGE" | |
#echo "SUITE = $SUITE" | |
#echo "RUN = $RUN" | |
## Build test command | |
COMMAND="XDEBUG_CONFIG=${XDEBUG_CONFIG} ${CAKE} test --stderr --log-junit \"${JUNITLOG}\"" | |
if [[ -n "$FILTER" ]] ; then | |
COMMAND="${COMMAND} --filter \"${FILTER}\"" | |
fi | |
if [[ -n "$COVERAGE" ]] ; then | |
COMMAND="${COMMAND} --coverage-clover \"${COVERAGE}\"" | |
fi | |
COMMAND="${COMMAND} \"${RUN}\"" | |
## Execute | |
#echo $COMMAND | |
eval $COMMAND |
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 bash | |
## | |
# | |
# Custom PHPUnit script for CakePHP 1.x on NetBaeans 8.0 | |
# | |
# require Stagehand_TestRunner <= 3.6 (see: https://github.com/piece/stagehand-testrunner/tree/3.0) | |
# | |
# @author Takashi Nojima [http://php-tips.com] | |
# @copyright 2014 Takashi Nojima | |
## | |
PROJECT_ROOT=$(cd "$(dirname "$(dirname "$0")")" && pwd) | |
TESTRUNNER=testrunner | |
APP="$PROJECT_ROOT/app" | |
CAKE_CORE="$PROJECT_ROOT/cake" | |
XDEBUG_CONFIG="idekey=netbeans-xdebug" | |
cd "$PROJECT_ROOT" | |
## parse options | |
while [[ $# -gt 2 ]] ; do | |
#echo ">> ${1} ${2}" | |
case $1 in | |
'--colors' ) | |
COLORS=1 | |
;; | |
'--log-junit' ) | |
JUNITLOG="$2" | |
shift | |
;; | |
'--bootstrap' ) | |
BOOTSTRAP="$2" | |
shift | |
;; | |
'--filter' ) | |
FILTER="$2" | |
shift | |
;; | |
'--coverage-clover' ) | |
COVERAGE=$2 | |
shift | |
;; | |
esac | |
shift | |
done | |
SUITE=$1 | |
RUN=$2 | |
## debug print | |
#echo "COLORS = $COLORS" | |
#echo "JUNITLOG = $JUNITLOG" | |
#echo "BOOTSTRAP = $BOOTSTRAP" | |
#echo "FILTER = $FILTER" | |
#echo "COVERAGE = $COVERAGE" | |
#echo "SUITE = $SUITE" | |
#echo "RUN = $RUN" | |
RUN=${RUN/--run=/} | |
METHOD=${FILTER//[\%\\b]/} | |
if [[ -n "$FILTER" && -n "$COVERAGE" ]] ; then | |
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" --test-method "$METHOD" "$RUN" | |
elif [[ -n "$FILTER" ]] ; then | |
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" --test-method "$METHOD" "$RUN" | |
elif [[ -n "$COVERAGE" ]] ; then | |
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" "$RUN" | |
else | |
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" "$RUN" | |
fi |
Stagehand_TestRunner を使えば 1.3系でも動かせる。 (testrunner.sh)
ただし、カバレッジ測定やエラー発生時のコードには飛べない。
引数の数チェックを修正
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
プロジェクトフォルダ内の
nbproject/
直下に設置するのを前提