bashunit
bashunit copied to clipboard
Provide argument to stop test *methods* when first assertion fails
Currently if a given test, e.g. test_foo has more than one assertion, and the first assertion fails, it will continue to run the others in that test method.
This leads to misleading output because those assertions are almost guaranteed to fail. For example:
test_foo() {
run_some_function > $OUTPUT_FILE
assert_exit_code "0"
# Check the contents of the file
assert_file_contains "$OUTPUT_FILE" "[abc]"
}
My output shows:
✗ Failed: foo
Expected '0'
to be '1'
✗ Failed: foo
Expected '/tmp/tmp.dGM4TtUViV'
to contain '[abc]'
If the exit code is non-zero, the output file likely hasn't been written or isn't worth analyzing.
I would like to see a new flag, --fail-tests-fast or similar which enables this behavior.
NOTE: This was previously discussed in issue #67 and marked as completed, but I don't think it's working.
When we execute a function if it has 2 assert, if the first one fails, we should stop the execution of the test, mark it as failed and jump to the next test without stopping the execution of the tests.
Have you tried using this option ./bashunit --stop-on-failure ?
https://bashunit.typeddevs.com/command-line#stop-on-failure