func (executor *specExecutor) executeStep(protoStep *gauge_messages.ProtoStep) bool { stepRequest := executor.createStepRequest(protoStep) executor.logger.Debug("Executing Step: %s", formatter.FormatStep(parser.CreateStepFromStepRequest(stepRequest))) protoStepExecResult := &gauge_messages.ProtoStepExecutionResult{} executor.currentExecutionInfo.CurrentStep = &gauge_messages.StepInfo{Step: stepRequest, IsFailed: proto.Bool(false)} beforeHookStatus := executor.executeBeforeStepHook() if beforeHookStatus.GetFailed() { protoStepExecResult.PreHookFailure = result.GetProtoHookFailure(beforeHookStatus) protoStepExecResult.ExecutionResult = &gauge_messages.ProtoExecutionResult{Failed: proto.Bool(true)} setStepFailure(executor.currentExecutionInfo, executor.logger) printStatus(beforeHookStatus, executor.logger) } else { executeStepMessage := &gauge_messages.Message{MessageType: gauge_messages.Message_ExecuteStep.Enum(), ExecuteStepRequest: stepRequest} stepExecutionStatus := executeAndGetStatus(executor.runner, executeStepMessage) if stepExecutionStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo, executor.logger) printStatus(stepExecutionStatus, executor.logger) } protoStepExecResult.ExecutionResult = stepExecutionStatus } afterStepHookStatus := executor.executeAfterStepHook() addExecutionTimes(protoStepExecResult, beforeHookStatus, afterStepHookStatus) if afterStepHookStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo, executor.logger) printStatus(afterStepHookStatus, executor.logger) protoStepExecResult.PostHookFailure = result.GetProtoHookFailure(afterStepHookStatus) protoStepExecResult.ExecutionResult.Failed = proto.Bool(true) } protoStepExecResult.Skipped = protoStep.StepExecutionResult.Skipped protoStepExecResult.SkippedReason = protoStep.StepExecutionResult.SkippedReason protoStep.StepExecutionResult = protoStepExecResult return protoStep.GetStepExecutionResult().GetExecutionResult().GetFailed() }
func (e *stepExecutor) executeStep(protoStep *gauge_messages.ProtoStep) bool { stepRequest := e.createStepRequest(protoStep) e.currentExecutionInfo.CurrentStep = &gauge_messages.StepInfo{Step: stepRequest, IsFailed: proto.Bool(false)} stepText := formatter.FormatStep(parser.CreateStepFromStepRequest(stepRequest)) e.consoleReporter.StepStart(stepText) protoStepExecResult := &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{}} e.notifyBeforeStepHook(protoStepExecResult) if !protoStepExecResult.ExecutionResult.GetFailed() { executeStepMessage := &gauge_messages.Message{MessageType: gauge_messages.Message_ExecuteStep.Enum(), ExecuteStepRequest: stepRequest} stepExecutionStatus := executeAndGetStatus(e.runner, executeStepMessage) if stepExecutionStatus.GetFailed() { setStepFailure(e.currentExecutionInfo) } protoStepExecResult.ExecutionResult = stepExecutionStatus } e.notifyAfterStepHook(protoStepExecResult) protoStepExecResult.Skipped = protoStep.StepExecutionResult.Skipped protoStepExecResult.SkippedReason = protoStep.StepExecutionResult.SkippedReason protoStep.StepExecutionResult = protoStepExecResult stepFailed := protoStep.GetStepExecutionResult().GetExecutionResult().GetFailed() if stepFailed { result := protoStep.GetStepExecutionResult().GetExecutionResult() e.consoleReporter.Errorf("\nFailed Step: %s", e.currentExecutionInfo.CurrentStep.Step.GetActualStepText()) e.consoleReporter.Errorf("Error Message: %s", strings.TrimSpace(result.GetErrorMessage())) e.consoleReporter.Errorf("Stacktrace: \n%s", result.GetStackTrace()) } e.consoleReporter.StepEnd(stepFailed) return stepFailed }
func (executor *specExecutor) executeStep(protoStep *gauge_messages.ProtoStep) bool { stepRequest := executor.createStepRequest(protoStep) stepText := formatter.FormatStep(parser.CreateStepFromStepRequest(stepRequest)) executor.consoleReporter.StepStart(stepText) protoStepExecResult := &gauge_messages.ProtoStepExecutionResult{} executor.currentExecutionInfo.CurrentStep = &gauge_messages.StepInfo{Step: stepRequest, IsFailed: proto.Bool(false)} beforeHookStatus := executor.executeBeforeStepHook() if beforeHookStatus.GetFailed() { protoStepExecResult.PreHookFailure = result.GetProtoHookFailure(beforeHookStatus) protoStepExecResult.ExecutionResult = &gauge_messages.ProtoExecutionResult{Failed: proto.Bool(true)} setStepFailure(executor.currentExecutionInfo, executor.consoleReporter) printStatus(beforeHookStatus, executor.consoleReporter) } else { executeStepMessage := &gauge_messages.Message{MessageType: gauge_messages.Message_ExecuteStep.Enum(), ExecuteStepRequest: stepRequest} stepExecutionStatus := executeAndGetStatus(executor.runner, executeStepMessage) if stepExecutionStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo, executor.consoleReporter) } protoStepExecResult.ExecutionResult = stepExecutionStatus } afterStepHookStatus := executor.executeAfterStepHook() addExecutionTimes(protoStepExecResult, beforeHookStatus, afterStepHookStatus) if afterStepHookStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo, executor.consoleReporter) printStatus(afterStepHookStatus, executor.consoleReporter) protoStepExecResult.PostHookFailure = result.GetProtoHookFailure(afterStepHookStatus) protoStepExecResult.ExecutionResult.Failed = proto.Bool(true) } protoStepExecResult.ExecutionResult.Message = afterStepHookStatus.Message protoStepExecResult.Skipped = protoStep.StepExecutionResult.Skipped protoStepExecResult.SkippedReason = protoStep.StepExecutionResult.SkippedReason protoStep.StepExecutionResult = protoStepExecResult stepFailed := protoStep.GetStepExecutionResult().GetExecutionResult().GetFailed() executor.consoleReporter.StepEnd(stepFailed) if stepFailed { result := protoStep.GetStepExecutionResult().GetExecutionResult() executor.consoleReporter.Error("Failed Step: %s", executor.currentExecutionInfo.CurrentStep.Step.GetActualStepText()) executor.consoleReporter.Error("Error Message: %s", strings.TrimSpace(result.GetErrorMessage())) executor.consoleReporter.Error("Stacktrace: \n%s", result.GetStackTrace()) } return stepFailed }
func (executor *specExecutor) executeStep(protoStep *gauge_messages.ProtoStep) bool { stepRequest := executor.createStepRequest(protoStep) stepWithResolvedArgs := parser.CreateStepFromStepRequest(stepRequest) executor.writer.StepStarting(stepWithResolvedArgs) protoStepExecResult := &gauge_messages.ProtoStepExecutionResult{} executor.currentExecutionInfo.CurrentStep = &gauge_messages.StepInfo{Step: stepRequest, IsFailed: proto.Bool(false)} beforeHookStatus := executor.executeBeforeStepHook() if beforeHookStatus.GetFailed() { protoStepExecResult.PreHookFailure = result.GetProtoHookFailure(beforeHookStatus) protoStepExecResult.ExecutionResult = &gauge_messages.ProtoExecutionResult{Failed: proto.Bool(true)} setStepFailure(executor.currentExecutionInfo) printStatus(beforeHookStatus, executor.writer) } else { executeStepMessage := &gauge_messages.Message{MessageType: gauge_messages.Message_ExecuteStep.Enum(), ExecuteStepRequest: stepRequest} stepExecutionStatus := executeAndGetStatus(executor.runner, executeStepMessage, executor.writer) if stepExecutionStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo) printStatus(stepExecutionStatus, executor.writer) } protoStepExecResult.ExecutionResult = stepExecutionStatus } afterStepHookStatus := executor.executeAfterStepHook() addExecutionTimes(protoStepExecResult, beforeHookStatus, afterStepHookStatus) if afterStepHookStatus.GetFailed() { setStepFailure(executor.currentExecutionInfo) printStatus(afterStepHookStatus, executor.writer) protoStepExecResult.PostHookFailure = result.GetProtoHookFailure(afterStepHookStatus) protoStepExecResult.ExecutionResult.Failed = proto.Bool(true) } executor.writer.StepFinished(stepWithResolvedArgs, protoStepExecResult.GetExecutionResult().GetFailed()) protoStep.StepExecutionResult = protoStepExecResult return protoStep.GetStepExecutionResult().GetExecutionResult().GetFailed() }