Created
June 28, 2013 11:12
-
-
Save kaosf/5883979 to your computer and use it in GitHub Desktop.
ShellScript でもテストを書こう with shUnit2 ref: http://qiita.com/ka_/items/1271df92c95e5d8084c2
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
APP_ROOT | |
|- a.sh | |
`- test/ | |
|- run.sh | |
|- a.txt | |
|- a-expected.txt | |
`- shunit2 |
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
#! /bin/sh | |
TEST_DIR=`dirname $0` | |
setUp() | |
{ | |
PREV_DIR=$PWD | |
cd $TEST_DIR | |
cp a.txt a.txt.bk | |
} | |
tearDown() | |
{ | |
if [ -f a.txt.bk ]; then | |
mv a.txt.bk a.txt | |
fi | |
cd $PREV_DIR | |
} | |
testA() | |
{ | |
../a.sh | |
diff a.txt a-expected.txt | |
assertEquals 0 $? | |
} | |
# load shunit2 | |
. $TEST_DIR/shunit2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment