Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Ran X tests." message is not accurate if a test exits #153

Open
vmaffet opened this issue Nov 19, 2021 · 0 comments
Open

"Ran X tests." message is not accurate if a test exits #153

vmaffet opened this issue Nov 19, 2021 · 0 comments

Comments

@vmaffet
Copy link

vmaffet commented Nov 19, 2021

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 Nth 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant