Skip to content

Instantly share code, notes, and snippets.

@kaosf
Created June 28, 2013 11:12
Show Gist options
  • Save kaosf/5883979 to your computer and use it in GitHub Desktop.
Save kaosf/5883979 to your computer and use it in GitHub Desktop.
ShellScript でもテストを書こう with shUnit2 ref: http://qiita.com/ka_/items/1271df92c95e5d8084c2
APP_ROOT
|- a.sh
`- test/
|- run.sh
|- a.txt
|- a-expected.txt
`- shunit2
#! /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