In this example the "some_command" executable will read the fake file and export the string "expected" into $ENVIRONMENT_VARIABLE, which is what we test.
testCommandWithFile() {
. some_command /testdirectory/mock/FAKE_FILE >/dev/null 2>&1
assertEquals "expected" "$ENVIRONMENT_VALUE"
return 0
}
Using mock data allows to perform unit tests, so we can be sure that the code works as expected.
This is important as with integration tests, there can always be uncertainties as to the interface availability or even changes in the data format.
Of course it also means, that if any data format has relevant changes, we need to update the mock data.
For an example how to loop through several lines and perform the same test look at "examples/mailcheck/email_validity.test".