3 // NOTE: This is a temporary copy of testing.go for Go 1.9 with the addition
4 // of "Helper" to the T interface. Go 1.9 at the time of typing is in RC
5 // and is set for release shortly. We'll support this on master as the default
6 // as soon as 1.9 is released.
15 // T is the interface that mimics the standard library *testing.T.
17 // In unit tests you can just pass a *testing.T struct. At runtime, outside
18 // of tests, you can pass in a RuntimeT struct from this package.
20 Error(args ...interface{})
21 Errorf(format string, args ...interface{})
22 Fatal(args ...interface{})
23 Fatalf(format string, args ...interface{})
28 Log(args ...interface{})
29 Logf(format string, args ...interface{})
32 // RuntimeT implements T and can be instantiated and run at runtime to
33 // mimic *testing.T behavior. Unlike *testing.T, this will simply panic
34 // for calls to Fatal. For calls to Error, you'll have to check the errors
35 // list to determine whether to exit yourself.
36 type RuntimeT struct {
40 func (t *RuntimeT) Error(args ...interface{}) {
41 log.Println(fmt.Sprintln(args...))
45 func (t *RuntimeT) Errorf(format string, args ...interface{}) {
46 log.Println(fmt.Sprintf(format, args...))
50 func (t *RuntimeT) Fatal(args ...interface{}) {
51 log.Println(fmt.Sprintln(args...))
55 func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
56 log.Println(fmt.Sprintf(format, args...))
60 func (t *RuntimeT) Fail() {
64 func (t *RuntimeT) FailNow() {
65 panic("testing.T failed, see logs for output (if any)")
68 func (t *RuntimeT) Failed() bool {
72 func (t *RuntimeT) Helper() {}
74 func (t *RuntimeT) Log(args ...interface{}) {
75 log.Println(fmt.Sprintln(args...))
78 func (t *RuntimeT) Logf(format string, args ...interface{}) {
79 log.Println(fmt.Sprintf(format, args...))