Skip to content

Commit

Permalink
Added Duration on GinkgoTestDescription
Browse files Browse the repository at this point in the history
Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
  • Loading branch information
eloycoto committed Oct 13, 2017
1 parent 11459a8 commit 5f49dad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ginkgo_dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ type GinkgoTestDescription struct {
FileName string
LineNumber int

Failed bool
Failed bool
Duration time.Duration
}

//CurrentGinkgoTestDescripton returns information about the current running test.
Expand All @@ -169,6 +170,7 @@ func CurrentGinkgoTestDescription() GinkgoTestDescription {
FileName: subjectCodeLocation.FileName,
LineNumber: subjectCodeLocation.LineNumber,
Failed: summary.HasFailureState(),
Duration: summary.RunTime,
}
}

Expand Down
7 changes: 4 additions & 3 deletions internal/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Spec struct {

state types.SpecState
runTime time.Duration
startTime time.Time
failure types.SpecFailure
previousFailures bool
}
Expand Down Expand Up @@ -97,7 +98,7 @@ func (spec *Spec) Summary(suiteID string) *types.SpecSummary {
ComponentTexts: componentTexts,
ComponentCodeLocations: componentCodeLocations,
State: spec.state,
RunTime: spec.runTime,
RunTime: time.Since(spec.startTime),
Failure: spec.failure,
Measurements: spec.measurementsReport(),
SuiteID: suiteID,
Expand All @@ -118,9 +119,9 @@ func (spec *Spec) Run(writer io.Writer) {
spec.previousFailures = true
}

startTime := time.Now()
spec.startTime = time.Now()
defer func() {
spec.runTime = time.Since(startTime)
spec.runTime = time.Since(spec.startTime)
}()

for sample := 0; sample < spec.subject.Samples(); sample++ {
Expand Down
1 change: 1 addition & 0 deletions internal/suite/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ var _ = Describe("Suite", func() {
Ω(description.LineNumber).Should(BeNumerically(">", 50))
Ω(description.LineNumber).Should(BeNumerically("<", 150))
Ω(description.Failed).Should(BeFalse())
Ω(description.Duration).Should(BeNumerically(">", 0))
})

Measure("should run measurements", func(b Benchmarker) {
Expand Down

0 comments on commit 5f49dad

Please sign in to comment.