diff --git a/internal/spec/spec.go b/internal/spec/spec.go index 96b779036..530f32bd6 100644 --- a/internal/spec/spec.go +++ b/internal/spec/spec.go @@ -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, diff --git a/internal/spec/spec_test.go b/internal/spec/spec_test.go index 3bab8887c..7011a42eb 100644 --- a/internal/spec/spec_test.go +++ b/internal/spec/spec_test.go @@ -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()) diff --git a/internal/suite/suite_test.go b/internal/suite/suite_test.go index 24f70cae2..6626dcd26 100644 --- a/internal/suite/suite_test.go +++ b/internal/suite/suite_test.go @@ -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() {