stretchr/testify

Diff is empty when lines are too long

Open

#746 opened on Mar 27, 2019

View on GitHub
 (6 comments) (7 reactions) (0 assignees)Go (25,958 stars) (1,704 forks)batch import
help wanted

Description

On assert.Equal failures, if the diff has long lines (due to complicated structs), instead of showing something like

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
					expected: ...
					actual: ...

					Diff:
					--- Expected
					+++ Actual
					<super long line...>
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

Currently the diff is completely cut off

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

This makes testing hard to check which lines differed.

Upon inspecting, indentation formatting of diff lines is using bufio.Scanner which has a default MaxScanTokenSize (64K) and would not parse long lines: https://github.com/stretchr/testify/blob/master/assert/assertions.go#L201

Can be fixed by either changing from bufio.Scanner to bufio.Reader or truncating long lines up to the max token size (or even provide a config to change max). Thoughts?

Contributor guide