Skip to content

Commit

Permalink
Fix comments on Spec Duration
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 Dec 22, 2017
1 parent 5f49dad commit 329d7ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ func (spec *Spec) Summary(suiteID string) *types.SpecSummary {
componentTexts[len(spec.containers)] = spec.subject.Text()
componentCodeLocations[len(spec.containers)] = spec.subject.CodeLocation()

runTime := spec.runTime
if runTime == 0 {
runTime = time.Since(spec.startTime)
}

return &types.SpecSummary{
IsMeasurement: spec.IsMeasurement(),
NumberOfSamples: spec.subject.Samples(),
ComponentTexts: componentTexts,
ComponentCodeLocations: componentCodeLocations,
State: spec.state,
RunTime: time.Since(spec.startTime),
RunTime: runTime,
Failure: spec.failure,
Measurements: spec.measurementsReport(),
SuiteID: suiteID,
Expand Down
7 changes: 7 additions & 0 deletions internal/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ var _ = Describe("Spec", func() {
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
})

It("should have a runtime which remains consistent after spec run", func() {
totalRunTime := summary.RunTime
Ω(totalRunTime).Should(BeNumerically(">=", 10*time.Millisecond))

Consistently(func() time.Duration { return spec.Summary("suite id").RunTime }).Should(Equal(totalRunTime))
})

It("should not be a measurement, or have a measurement summary", func() {
Ω(summary.IsMeasurement).Should(BeFalse())
Ω(summary.Measurements).Should(BeEmpty())
Expand Down
13 changes: 13 additions & 0 deletions internal/suite/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ var _ = Describe("Suite", func() {
"AfterSuite",
}))
})
Context("When afterEach info is needed", func() {
AfterEach(func() {
description := CurrentGinkgoTestDescription()
Ω(description.IsMeasurement).Should(BeFalse())
Ω(description.FileName).Should(ContainSubstring("suite_test.go"))
Ω(description.Failed).Should(BeFalse())
Ω(description.Duration).Should(BeNumerically(">", 0))
})

It("provides information about the current test", func() {
Ω(true).To(BeTrue())
})
})

Context("when told to randomize all specs", func() {
BeforeEach(func() {
Expand Down

0 comments on commit 329d7ed

Please sign in to comment.