Commit a53be35
Improve captureTestingT helper
This helper is used to capture the testing.TB interface, and compare
the log output with the expected output.
This is useful for testing and refactoring purposes.
This commit improves the helper by displaying:
- the captured and expected outputs on a newline.
- the special characters in the captured output, such as newlines and tabs.
Both help with readability.
Here is an example of the output before and after the change:
Before:
assertions_test.go:3422: Logged Error: Should be in error chain
expected: *assert.customError
in chain: "EOF" (*errors.errorString)
assertions_test.go:3422: Should log Error: Should be in error chain:
expected: *assert.customError
in chain: "EOF" (*errors.errorString)
After:
assertions_test.go:3394: Recorded Error: "Should be in error chain:\nexpected: *assert.customError\nin chain: \"EOF\" (*errors.errorString)\n"
assertions_test.go:3394: Expected Error: "Should be in error chain\nexpected: *assert.customError\nin chain: \"EOF\" (*errors.errorString)"
The new format helps to identify the differences:
- the missing colon after "Should be in error chain"
- the extra newline in the captured output
Note: I spent 10 minutes on this change, because I lost 10 minutes in
finding the differences between the captured and expected output on a
refactoring I was doing.1 parent aafb604 commit a53be35
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3675 | 3675 | | |
3676 | 3676 | | |
3677 | 3677 | | |
3678 | | - | |
| 3678 | + | |
3679 | 3679 | | |
3680 | 3680 | | |
3681 | 3681 | | |
3682 | 3682 | | |
3683 | | - | |
| 3683 | + | |
3684 | 3684 | | |
3685 | 3685 | | |
3686 | 3686 | | |
3687 | 3687 | | |
3688 | 3688 | | |
3689 | 3689 | | |
3690 | 3690 | | |
3691 | | - | |
| 3691 | + | |
3692 | 3692 | | |
3693 | 3693 | | |
3694 | | - | |
| 3694 | + | |
3695 | 3695 | | |
3696 | 3696 | | |
3697 | 3697 | | |
| |||
0 commit comments