Skip to content

Commit 32736be

Browse files
authored
fix(assert): use distinct error message for assert_not_same and assert_not_equals (#605)
1 parent ee2fe68 commit 32736be

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Fixed
6+
- Fix misleading error message for `assert_not_same` and `assert_not_equals` on failure #604
7+
58
### Added
69
- Add `--jobs N` flag to limit parallel test concurrency (e.g., `--jobs 4`)
710
- Add `--watch` mode to automatically re-run tests when files change

src/assert.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function assert_not_equals() {
169169
local label
170170
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
171171
bashunit::assert::mark_failed
172-
bashunit::console_results::print_failed_test "${label}" "${expected_cleaned}" "but got " "${actual_cleaned}"
172+
bashunit::console_results::print_failed_test "${label}" "${expected_cleaned}" "to not be" "${actual_cleaned}"
173173
return
174174
fi
175175

@@ -224,7 +224,7 @@ function assert_not_same() {
224224
local label
225225
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
226226
bashunit::assert::mark_failed
227-
bashunit::console_results::print_failed_test "${label}" "${expected}" "but got " "${actual}"
227+
bashunit::console_results::print_failed_test "${label}" "${expected}" "to not be" "${actual}"
228228
return
229229
fi
230230

tests/unit/assert_advanced_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function test_successful_assert_not_same() {
1818
}
1919

2020
function test_unsuccessful_assert_not_same() {
21-
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert not same" "1" "but got " "1")" \
21+
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert not same" "1" "to not be" "1")" \
2222
"$(assert_not_same "1" "1")"
2323
}
2424

tests/unit/assert_string_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function test_successful_assert_not_equals() {
88
}
99

1010
function test_unsuccessful_assert_not_equals() {
11-
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert not equals" "1" "but got " "1")" \
11+
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert not equals" "1" "to not be" "1")" \
1212
"$(assert_not_equals "1" "1")"
1313
}
1414

@@ -18,7 +18,7 @@ function test_unsuccessful_assert_not_equals_with_special_chars() {
1818

1919
assert_equals "$(bashunit::console_results::print_failed_test \
2020
"Unsuccessful assert not equals with special chars" \
21-
"$str1" "but got " "$str2")" \
21+
"$str1" "to not be" "$str2")" \
2222
"$(assert_not_equals "$str1" "$str2")"
2323
}
2424

0 commit comments

Comments
 (0)