stretchr / testify

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

suite: add wrappers for Log and Logf functions #1553

Open fredrb opened 4 months ago

fredrb commented 4 months ago

Summary

Introduce wrapper methods for testing.T Log and Logf methods.

Changes

Motivation

I frequently use t.Log and t.Logf to add verbose log to my tests, usually while I'm still creating them. Therefore, I find myself often writting the following snippet:

func (s *mySuite) TestA() {
        s.T().Logf(...)
}

Example usage

For that reason, it would be a nice improvement if the suite struct implemented wrappers to these functions, so I could write instead:

func (s *mySuite) TestA() {
        s.Logf(...)
}

Related issues

None.

fredrb commented 3 months ago

@dolmen could you please take a look if this change is good to be merged? Do you have any other concerns about doing this?