I am using testing package to test my code. Currently I am only logging errors when errors are not 'nil' like:
if err != nil {
t.Errorf("Failed to initialise Client %s", err)
}
I also want to print success messages when error is nil using the same t *testing.T
instance. Is there a way to do this?
You can use Log or Logf methods:
t.Log("It works like Println")
t.Logf("It works like Printf")
Check official documents for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With