Skip to content

Commit

Permalink
Added changelog and doc; additional test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ceejatec committed Apr 24, 2024
1 parent bb52497 commit 6e9d097
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased](https://github.com/TypedDevs/bashunit/compare/0.11.0...main)

- Add `fail()` function

## [0.11.0](https://github.com/TypedDevs/bashunit/compare/0.10.1...0.11.0) - 2024-03-02

- Add `--upgrade` option to `./bashunit`
Expand Down
17 changes: 17 additions & 0 deletions docs/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,3 +856,20 @@ function test_failure() {
}
```
:::

## fail
> `fail "failure message"`
Unambiguously reports an error message. Useful for reporting specific message
when testing situations not covered by any `assert_*` functions.

::: code-group
```bash [Example]
function test_success() {
true || fail "This will never fail"
}
function test_failure() {
[ $(date +%-H) -lt 6 ] || fail "It's late, go to bed"
}
```
:::
4 changes: 4 additions & 0 deletions tests/unit/assert_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

function test_successful_fail() {
true || fail "This cannot fail"
}

function test_unsuccessful_fail() {
assert_equals\
"$(console_results::print_failure_message "Unsuccessful fail" "Failure message")"\
Expand Down

0 comments on commit 6e9d097

Please sign in to comment.