stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
23.53k stars 1.6k forks source link

Truncate very long objects in test failure messages #1646

Open brackendawson opened 1 month ago

brackendawson commented 1 month ago

Summary

Truncate object representations in test failure output messages that would cause the message to be too long to scan.

This is a different approach than that in #1559. I feel this is more appropriate because is it safer. The other approach has the potential to allocate excessive memory and to print excessive output to the console.

Changes

Motivation

So that people don't see no output in the failure message when making assertions (such as Len) against very long objects.

Related issues

Closes #1525