示例#1
0
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
}
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)
}