mirror of
https://github.com/stretchr/testify.git
synced 2025-08-14 12:38:46 +00:00
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.