-
Notifications
You must be signed in to change notification settings - Fork 3
/
testinfo.go
64 lines (53 loc) · 1.48 KB
/
testinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package barrier
import (
"io"
"time"
)
// A TestInfo contains various information about a test.
type TestInfo struct {
data interface{}
iteration int
testID string
timeOfLastStep time.Time
timeout time.Duration
header io.Writer
writer io.Writer
suite *suiteInfo
}
// SetupInfo returns the eventual object stored by the Setup function.
func (t TestInfo) SetupInfo() interface{} {
return t.data
}
// SuiteSetupInfo returns the eventual object stored by the Suite Setup function.
func (t TestInfo) SuiteSetupInfo() interface{} {
return t.suite.data
}
// Stash provides the callers data that may store configs/runtime they need
func (t TestInfo) Stash() interface{} {
return t.suite.stash
}
// Iteration returns the test iteration number.
func (t TestInfo) Iteration() int {
return t.iteration
}
// TestID returns the test ID
func (t TestInfo) TestID() string {
return t.testID
}
// WriteHeader performs a write at the header
func (t TestInfo) WriteHeader(p []byte) (n int, err error) {
return t.header.Write(p)
}
// Write performs a write
func (t TestInfo) Write(p []byte) (n int, err error) {
return t.writer.Write(p)
}
// TimeSinceLastStep provides the time since last step or assertion
func (t TestInfo) TimeSinceLastStep() string {
d := time.Since(t.timeOfLastStep)
return d.Round(time.Millisecond).String()
}
// Timeout provides the duration before the test timeout.
func (t TestInfo) Timeout() time.Duration {
return t.timeout
}