shunit2
shunit2 copied to clipboard
Mock and expect
I was just wondering, what is the preferred way of doing something like the example below (which doesn't seem to work):
# my_command.test.sh
# Test my_command in fact does call my_other_command
. src/my_command.sh # Assuming my_command is a function
CALLS_COUNT=0
my_other_command {
# do something
CALLS_COUNT=$(( CALLS_COUNT + 1 ))
}
tesMyCommand() {
my_command
assertEquals 1 $CALLS_COUNT
}
NOTE: This is assumed to be called like this: shunit2 my_command.test.sh
Hi what is exactly not working, can you provide the output?
Something seems to be running in a sub-shell, and when I test the value it's always 0;
Something seems to be running in a sub-shell, and when I test the value it's always 0;
Okay, would you mind posting the output of your test script?