Ejemplo n.º 1
0
func (exe *simpleExecution) executeStream(specs *specList) *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	initSuiteDataStoreResult := exe.initializeSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		exe.logger.Error("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
	} else {
		beforeSuiteHookExecResult := exe.startExecution()
		if beforeSuiteHookExecResult.GetFailed() {
			result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
			exe.suiteResult.SetFailure()
		} else {
			for !specs.isEmpty() {
				exe.executeSpec(specs.getSpec())
			}
		}
		afterSuiteHookExecResult := exe.endExecution()
		if afterSuiteHookExecResult.GetFailed() {
			result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
			exe.suiteResult.SetFailure()
		}
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 2
0
func (executor *specExecutor) executeScenario(scenario *parser.Scenario) *result.ScenarioResult {
	executor.currentExecutionInfo.CurrentScenario = &gauge_messages.ScenarioInfo{Name: proto.String(scenario.Heading.Value), Tags: getTagValue(scenario.Tags), IsFailed: proto.Bool(false)}
	scenarioResult := &result.ScenarioResult{parser.NewProtoScenario(scenario)}
	executor.addAllItemsForScenarioExecution(scenario, scenarioResult)
	scenarioResult.ProtoScenario.Skipped = proto.Bool(false)
	if _, ok := executor.errMap.scenarioErrs[scenario]; ok {
		executor.setSkipInfoInResult(scenarioResult, scenario)
		return scenarioResult
	}
	executor.consoleReporter.ScenarioStart(scenario.Heading.Value)

	beforeHookExecutionStatus := executor.executeBeforeScenarioHook(scenarioResult)
	if beforeHookExecutionStatus.GetFailed() {
		result.AddPreHook(scenarioResult, beforeHookExecutionStatus)
		setScenarioFailure(executor.currentExecutionInfo)
		printStatus(beforeHookExecutionStatus, executor.consoleReporter)
	} else {
		executor.executeContextItems(scenarioResult)
		if !scenarioResult.GetFailure() {
			executor.executeScenarioItems(scenarioResult)
		}
		executor.executeTearDownItems(scenarioResult)
	}

	afterHookExecutionStatus := executor.executeAfterScenarioHook(scenarioResult)
	result.AddPostHook(scenarioResult, afterHookExecutionStatus)
	scenarioResult.UpdateExecutionTime()
	if afterHookExecutionStatus.GetFailed() {
		setScenarioFailure(executor.currentExecutionInfo)
		printStatus(afterHookExecutionStatus, executor.consoleReporter)
	}
	executor.consoleReporter.ScenarioEnd(scenarioResult.GetFailure())

	return scenarioResult
}
Ejemplo n.º 3
0
func (exe *simpleExecution) start() *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	exe.suiteResult.SpecsSkippedCount = len(exe.errMaps.specErrs)
	initSuiteDataStoreResult := exe.initializeSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		exe.logger.Error("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
	} else {
		beforeSuiteHookExecResult := exe.startExecution()
		if beforeSuiteHookExecResult.GetFailed() {
			result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
			exe.suiteResult.SetFailure()
			printStatus(beforeSuiteHookExecResult, exe.logger)
		} else {
			for _, specificationToExecute := range exe.specifications {
				exe.executeSpec(specificationToExecute)
			}
		}
		afterSuiteHookExecResult := exe.endExecution()
		if afterSuiteHookExecResult.GetFailed() {
			result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
			exe.suiteResult.SetFailure()
			printStatus(afterSuiteHookExecResult, exe.logger)
		}
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 4
0
func (exe *simpleExecution) start() *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	beforeSuiteHookExecResult := exe.startExecution()
	if beforeSuiteHookExecResult.GetFailed() {
		result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
		exe.suiteResult.SetFailure()
	} else {
		for _, specificationToExecute := range exe.specifications {
			executor := newSpecExecutor(specificationToExecute, exe.runner, exe.pluginHandler, getDataTableRows(specificationToExecute.DataTable.Table.GetRowCount()), exe.logger)
			protoSpecResult := executor.execute()
			exe.suiteResult.AddSpecResult(protoSpecResult)
		}
	}
	afterSuiteHookExecResult := exe.endExecution()
	if afterSuiteHookExecResult.GetFailed() {
		result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
		exe.suiteResult.SetFailure()
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 5
0
func (executor *specExecutor) executeScenario(scenario *parser.Scenario) *result.ScenarioResult {
	executor.currentExecutionInfo.CurrentScenario = &gauge_messages.ScenarioInfo{Name: proto.String(scenario.Heading.Value), Tags: getTagValue(scenario.Tags), IsFailed: proto.Bool(false)}
	scenarioResult := &result.ScenarioResult{parser.NewProtoScenario(scenario)}
	executor.addAllItemsForScenarioExecution(scenario, scenarioResult)
	if _, ok := executor.errMap.scenarioErrs[scenario]; ok {
		executor.specResult.ScenarioSkippedCount += 1
		return scenarioResult
	}
	executor.logger.Info("Executing scenario: %s", scenario.Heading.Value)
	beforeHookExecutionStatus := executor.executeBeforeScenarioHook(scenarioResult)
	if beforeHookExecutionStatus.GetFailed() {
		result.AddPreHook(scenarioResult, beforeHookExecutionStatus)
		setScenarioFailure(executor.currentExecutionInfo)
	} else {
		executor.executeContextItems(scenarioResult)
		if !scenarioResult.GetFailure() {
			executor.executeScenarioItems(scenarioResult)
		}
	}

	afterHookExecutionStatus := executor.executeAfterScenarioHook(scenarioResult)
	result.AddPostHook(scenarioResult, afterHookExecutionStatus)
	scenarioResult.UpdateExecutionTime()
	return scenarioResult
}
Ejemplo n.º 6
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
}
Ejemplo n.º 7
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
}