Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Adds a Logf utility method to the testing object
Browse files Browse the repository at this point in the history
  • Loading branch information
ameteiko committed Aug 12, 2022
1 parent 35266e2 commit a2de1b5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions godog/testing/t.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testing

import (
"fmt"
"strings"
)

// testingT is an interface wrapper around *testing.T
Expand All @@ -14,9 +15,15 @@ type T struct {
err error
}

// Logf formats its arguments according to the format, analogous to Printf. A final newline is added if not provided.
func (t *T) Logf(format string, args ...any) {
fmt.Printf(strings.Join(strings.Split(fmt.Sprintf(format, args...), "\n"), "\n"))
}

func (t *T) Errorf(format string, args ...interface{}) {
t.err = fmt.Errorf(format, args...)
}

func (t *T) Err() error {
return t.err
}
Expand Down

0 comments on commit a2de1b5

Please sign in to comment.