Example #1
0
func (specExecutor *specExecutor) execute() *result.SpecResult {
	specInfo := &gauge_messages.SpecInfo{Name: proto.String(specExecutor.specification.Heading.Value),
		FileName: proto.String(specExecutor.specification.FileName),
		IsFailed: proto.Bool(false), Tags: getTagValue(specExecutor.specification.Tags)}
	specExecutor.currentExecutionInfo = &gauge_messages.ExecutionInfo{CurrentSpec: specInfo}
	specExecutor.specResult = parser.NewSpecResult(specExecutor.specification)
	resolvedSpecItems := specExecutor.resolveItems(specExecutor.specification.GetSpecItems())
	specExecutor.specResult.AddSpecItems(resolvedSpecItems)
	if _, ok := specExecutor.errMap.specErrs[specExecutor.specification]; ok {
		return specExecutor.getSkippedSpecResult()
	}
	specExecutor.logger.Info("Executing specification: %s", specInfo.GetName())
	beforeSpecHookStatus := specExecutor.executeBeforeSpecHook()
	if beforeSpecHookStatus.GetFailed() {
		result.AddPreHook(specExecutor.specResult, beforeSpecHookStatus)
		setSpecFailure(specExecutor.currentExecutionInfo)
	} else {
		dataTableRowCount := specExecutor.specification.DataTable.Table.GetRowCount()
		if dataTableRowCount == 0 {
			scenarioResult := specExecutor.executeScenarios()
			specExecutor.specResult.AddScenarioResults(scenarioResult)
		} else {
			specExecutor.executeTableDrivenScenarios()
		}
	}

	afterSpecHookStatus := specExecutor.executeAfterSpecHook()
	if afterSpecHookStatus.GetFailed() {
		result.AddPostHook(specExecutor.specResult, afterSpecHookStatus)
		setSpecFailure(specExecutor.currentExecutionInfo)
	}
	specExecutor.specResult.Skipped = specExecutor.specResult.ScenarioSkippedCount > 0
	return specExecutor.specResult
}
Example #2
0
func (specExecutor *specExecutor) execute() *result.SpecResult {
	specInfo := &gauge_messages.SpecInfo{Name: proto.String(specExecutor.specification.Heading.Value),
		FileName: proto.String(specExecutor.specification.FileName),
		IsFailed: proto.Bool(false), Tags: getTagValue(specExecutor.specification.Tags)}
	specExecutor.currentExecutionInfo = &gauge_messages.ExecutionInfo{CurrentSpec: specInfo}

	specExecutor.writer.SpecHeading(specInfo.GetName())

	specExecutor.specResult = parser.NewSpecResult(specExecutor.specification)
	resolvedSpecItems := specExecutor.resolveItems(specExecutor.specification.GetSpecItems())
	specExecutor.specResult.AddSpecItems(resolvedSpecItems)

	beforeSpecHookStatus := specExecutor.executeBeforeSpecHook()
	if beforeSpecHookStatus.GetFailed() {
		result.AddPreHook(specExecutor.specResult, beforeSpecHookStatus)
		setSpecFailure(specExecutor.currentExecutionInfo)
	} else {
		for _, step := range specExecutor.specification.Contexts {
			specExecutor.writer.Step(step)
		}
		dataTableRowCount := specExecutor.specification.DataTable.Table.GetRowCount()
		if dataTableRowCount == 0 {
			scenarioResult := specExecutor.executeScenarios()
			specExecutor.specResult.AddScenarioResults(scenarioResult)
		} else {
			specExecutor.executeTableDrivenScenarios()
		}
	}

	afterSpecHookStatus := specExecutor.executeAfterSpecHook()
	if afterSpecHookStatus.GetFailed() {
		result.AddPostHook(specExecutor.specResult, afterSpecHookStatus)
		setSpecFailure(specExecutor.currentExecutionInfo)
	}
	return specExecutor.specResult
}