Skip to content

Commit bbf146c

Browse files
authored
Merge pull request #11 from jaypipes/elapsed-granularity
ensure elapsed time is stored to testunit
2 parents c158d81 + 9f0a93b commit bbf146c

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

scenario/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ func (s *Scenario) runExternal(ctx context.Context, run *run.Run) error {
136136
}
137137
if len(res.Failures()) > 0 {
138138
tu.FailNow()
139+
} else {
140+
tu.Finish() // necessary for elapsed timer to stop
139141
}
140142
scenOK = scenOK && !tu.Failed()
141143

testunit/testunit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type TestUnit struct {
4848
elapsed time.Duration
4949
}
5050

51-
func (u *TestUnit) finish() {
51+
func (u *TestUnit) Finish() {
5252
u.Lock()
5353
u.elapsed += time.Since(u.started)
5454
u.done = true
@@ -100,7 +100,7 @@ func (u *TestUnit) Failed() bool {
100100
// Execution will continue at the next test unit.
101101
func (u *TestUnit) FailNow() {
102102
u.Fail()
103-
u.finish()
103+
u.Finish()
104104
}
105105

106106
func (u *TestUnit) log(s string) {
@@ -181,7 +181,7 @@ func (u *TestUnit) SkipNow() {
181181
u.Lock()
182182
defer u.RUnlock()
183183
u.skipped = true
184-
u.finish()
184+
u.Finish()
185185
}
186186

187187
// Skipped reports whether the test was skipped.

0 commit comments

Comments
 (0)