Skip to content

Commit

Permalink
Make testlib.T match the footprint of testing.T
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidgecka committed Sep 1, 2014
1 parent 56e763c commit 818a050
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions testlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ func (t *T) Errorf(format string, args ...interface{}) {
t.t.Error(t.makeStack(fmt.Sprintf(format, args...)))
}

// A wrapper around testing.T.FailNow()
func (t *T) FailNow() {
t.t.FailNow()
}

// A wrapper around testing.T.Failed()
func (t *T) Failed() bool {
return t.t.Failed()
}

// This is a wrapper around Fatal in order to provide much nicer output.
// Specifically this will output a full stack trace rather than just the
// failing line. This is optimal because it makes debugging when loops
Expand All @@ -138,6 +148,16 @@ func (t *T) Fatalf(format string, args ...interface{}) {
t.t.Fatal(t.makeStack(fmt.Sprintf(format, args...)))
}

// A wrapper for testing.T.Log to make object passing easier.
func (t *T) Log(args ...interface{}) {
t.t.Log(args...)
}

// A wrapper for testing.T.Logf to make object passing easier.
func (t *T) Logf(format string, args ...interface{}) {
t.t.Logf(format, args...)
}

// Gets the function name of the running test. This is useful since there is
// no other programatic way of finding out which test is running.
func (t *T) Name() string {
Expand Down Expand Up @@ -173,3 +193,18 @@ func (t *T) Name() string {

return t.name
}

// A wrapper around testing.T.SkipNow()
func (t *T) SkipNow() {
t.t.SkipNow()
}

// Wraps around testing.T.Skipf except this provides a full stack trace.
func (t *T) Skipf(format string, args ...interface{}) {
t.t.Skip(t.makeStack(fmt.Sprintf(format, args...)))
}

// A wrapper around testing.T.Skipped()
func (t *T) Skipped() bool {
return t.t.Skipped()
}

0 comments on commit 818a050

Please sign in to comment.