Skip to content

Instantly share code, notes, and snippets.

@simlun
Created July 6, 2012 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simlun/3058467 to your computer and use it in GitHub Desktop.
Save simlun/3058467 to your computer and use it in GitHub Desktop.
ATDD shell scripting using shUnit2
#!/bin/sh
# Setup
SUT=../system_under_test.sh
INPUT_FILE=sample_input.txt
EXPECTED_OUTPUT_FILE=expected_output.txt
EXPECTED_STATUS_CODE=0
# The test
testStatusCodeAndResponse()
{
response=`$SUT < $INPUT_FILE`
assertEquals $EXPECTED_STATUS_CODE $?
assertEquals "$(cat $EXPECTED_OUTPUT_FILE)" "$response"
}
# Load shunit2
. lib/shunit2
@simlun
Copy link
Author

simlun commented Jul 6, 2012

Using http://code.google.com/p/shunit2/ version 2.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment