Skip to content

Commit

Permalink
Fix bug where negative durations are reported when tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Stein Fletcher committed Oct 27, 2019
1 parent f583ff5 commit 48c3507
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
coverage.out
resources/_gen/images/
.DS_Store
.sequence
5 changes: 2 additions & 3 deletions apitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ func (r *Response) End() Result {
apiTest := r.apiTest
defer func() {
if apiTest.debugEnabled {
apiTest.finished = time.Now()
fmt.Println(fmt.Sprintf("Duration: %s\n", apiTest.finished.Sub(apiTest.started)))
}
}()
Expand All @@ -468,14 +469,12 @@ func (r *Response) End() Result {
apiTest.t.Fatal("either define a http.Handler or enable networking")
}

apiTest.started = time.Now()
if apiTest.reporter != nil {
res := apiTest.report()
return Result{Response: res}
}

apiTest.started = time.Now()
res := r.runTest()
apiTest.finished = time.Now()

return Result{Response: res}
}
Expand Down

0 comments on commit 48c3507

Please sign in to comment.