10 // T is the interface that mimics the standard library *testing.T.
12 // In unit tests you can just pass a *testing.T struct. At runtime, outside
13 // of tests, you can pass in a RuntimeT struct from this package.
15 Error(args ...interface{})
16 Errorf(format string, args ...interface{})
20 Fatal(args ...interface{})
21 Fatalf(format string, args ...interface{})
22 Log(args ...interface{})
23 Logf(format string, args ...interface{})
25 Skip(args ...interface{})
27 Skipf(format string, args ...interface{})
31 // RuntimeT implements T and can be instantiated and run at runtime to
32 // mimic *testing.T behavior. Unlike *testing.T, this will simply panic
33 // for calls to Fatal. For calls to Error, you'll have to check the errors
34 // list to determine whether to exit yourself. Name and Skip methods are
35 // unimplemented noops.
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) Log(args ...interface{}) {
73 log.Println(fmt.Sprintln(args...))
76 func (t *RuntimeT) Logf(format string, args ...interface{}) {
77 log.Println(fmt.Sprintf(format, args...))
80 func (t *RuntimeT) Name() string { return "" }
81 func (t *RuntimeT) Skip(args ...interface{}) {}
82 func (t *RuntimeT) SkipNow() {}
83 func (t *RuntimeT) Skipf(format string, args ...interface{}) {}
84 func (t *RuntimeT) Skipped() bool { return false }