Skip to content

Commit c92a582

Browse files
authored
Merge pull request #526 from TypedDevs/feat/492-stop-func-after-first-assesrt-fails
Stop test function after first assert fails
2 parents 32cc0cd + 87bb8c3 commit c92a582

10 files changed

Lines changed: 138 additions & 44 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
- `bashunit init [dir]` - initialize project (replaces `--init`)
1717
- `bashunit learn` - interactive tutorial (replaces `--learn`)
1818
- `bashunit upgrade` - upgrade to latest (replaces `--upgrade`)
19+
- **BREAKING:** Tests now stop at first assertion failure within a test function
20+
- Matches PHPUnit and Jest default behavior
21+
- Subsequent assertions in the same test are skipped after a failure
22+
- Other test functions continue to run normally
1923

2024
### Fixed
2125
- Stop executing remaining commands in `set_up`/`tear_down` after first failure

docs/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ Force to stop the runner right after encountering one failing test. `false` by d
8585

8686
Similar as using `-S|--stop-on-failure` option on the [command line](/command-line#stop-on-failure).
8787

88+
::: tip Assertion behavior
89+
When an assertion fails within a test, subsequent assertions in the same test are automatically skipped. This matches popular testing libraries default behavior and prevents misleading failures caused by earlier assertion failures.
90+
91+
The `--stop-on-failure` flag is separate – it stops the entire test runner after a failing **test**, while assertion-level stopping happens automatically within each test.
92+
:::
93+
8894
## Show header
8995

9096
> `BASHUNIT_SHOW_HEADER=true|false`

docs/custom-asserts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
Check the internal functional tests: `tests/functional/custom_asserts_test.sh` ([link](https://github.com/TypedDevs/bashunit/blob/main/tests/functional/custom_asserts_test.sh))
77
:::
88

9+
::: info Assertion behavior
10+
When using the bashunit facade, assertions automatically respect the guard behavior: if a previous assertion in the same test already failed, subsequent assertions are skipped. This matches popular testing libraries default behavior.
11+
:::
12+
913
## assertion_failed
1014
> `bashunit::assertion_failed <expected> <actual> <failure_condition_message?>`
1115

0 commit comments

Comments
 (0)