"Ran X tests." message is not accurate if a test exits
vmaffet opened this issue · comments
I have been testing some functions that occasionaly call exit 1
.
Those functions stop the execution of the test file.
Before stopping, shunit2
always says Ran X tests.
, where X
is the number of tests in my test file.
However, if the N
th test exits, then we actually ran N-1
tests, not X
.
Here is a file that reproduces the issue:
#! /bin/sh
# file: examples/exit_test.sh
test_one() {
assertTrue 0
}
test_two() {
exit
assertTrue 0
}
test_three() {
assertTrue 0
}
test_four() {
assertTrue 0
}
# Load and run shUnit2.
. ../shunit2
The console output is currently:
test_one
test_two
ASSERT:unknown failure encountered running a test
Ran 4 tests.
FAILED (failures=1)
Outputting something like Ran 1 out of 4 tests.
would be more accurate.