func (runner *SpecRunner) reportSpecDidComplete(spec *spec.Spec) { summary := spec.Summary(runner.suiteID) for i := len(runner.reporters) - 1; i >= 1; i-- { runner.reporters[i].SpecDidComplete(summary) } if spec.Failed() { runner.writer.DumpOut() } runner.reporters[0].SpecDidComplete(summary) }
func (runner *SpecRunner) reportSpecWillRun(spec *spec.Spec) { runner.writer.Truncate() summary := spec.Summary(runner.suiteID) for _, reporter := range runner.reporters { reporter.SpecWillRun(summary) } }
func (runner *SpecRunner) runSpec(spec *spec.Spec) (passed bool) { maxAttempts := 1 if runner.config.FlakeAttempts > 0 { // uninitialized configs count as 1 maxAttempts = runner.config.FlakeAttempts } for i := 0; i < maxAttempts; i++ { runner.reportSpecWillRun(spec.Summary(runner.suiteID)) runner.runningSpec = spec spec.Run(runner.writer) runner.runningSpec = nil runner.reportSpecDidComplete(spec.Summary(runner.suiteID), spec.Failed()) if !spec.Failed() { return true } } return false }
newRunner := func(config config.GinkgoConfigType, beforeSuiteNode leafnodes.SuiteNode, afterSuiteNode leafnodes.SuiteNode, specs ...*spec.Spec) *SpecRunner { return New("description", beforeSuiteNode, spec.NewSpecs(specs), afterSuiteNode, []reporters.Reporter{reporter1, reporter2}, writer, config) } BeforeEach(func() { reporter1 = reporters.NewFakeReporter() reporter2 = reporters.NewFakeReporter() writer = Writer.NewFake() failer = Failer.New() thingsThatRan = []string{} }) Describe("Running and Reporting", func() { var specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec *spec.Spec BeforeEach(func() { specA = newSpec("spec A", noneFlag, false) pendingSpec = newSpec("pending spec", pendingFlag, false) anotherPendingSpec = newSpec("another pending spec", pendingFlag, false) failedSpec = newSpec("failed spec", noneFlag, true) specB = newSpec("spec B", noneFlag, false) skippedSpec = newSpec("skipped spec", noneFlag, false) skippedSpec.Skip() runner = newRunner(config.GinkgoConfigType{RandomSeed: 17}, newBefSuite("BefSuite", false), newAftSuite("AftSuite", false), specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec) runner.Run() }) It("should skip skipped/pending tests", func() { Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "spec A", "failed spec", "spec B", "AftSuite"}))
func (runner *SpecRunner) reportSpecDidComplete(spec *spec.Spec) { summary := spec.Summary(runner.suiteID) for _, reporter := range runner.reporters { reporter.SpecDidComplete(summary) } }