Skip to content

Commit

Permalink
Log messages after scenario now can be canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Sep 4, 2018
1 parent 5e4e824 commit 063cde7
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/ReportPortal.SpecFlowPlugin/ReportPortalHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ public void AfterScenario()
Comment = this.ScenarioContext.TestError?.Message
};

currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = this.ScenarioContext.TestError?.ToString()
});

break;
case ScenarioExecutionStatus.BindingError:
status = Status.Failed;
Expand All @@ -204,13 +197,6 @@ public void AfterScenario()
Comment = this.ScenarioContext.TestError?.Message
};

currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = this.ScenarioContext.TestError?.Message
});

break;
case ScenarioExecutionStatus.UndefinedStep:
status = Status.Failed;
Expand All @@ -221,13 +207,6 @@ public void AfterScenario()
Comment = new MissingStepDefinitionException().Message
};

currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = new MissingStepDefinitionException().Message
});

break;
case ScenarioExecutionStatus.StepDefinitionPending:
status = Status.Failed;
Expand All @@ -253,8 +232,33 @@ public void AfterScenario()

if (!eventArg.Canceled)
{
if(this.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.TestError)
{
currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = this.ScenarioContext.TestError?.ToString()
});
} else if (this.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.BindingError)
{
currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = this.ScenarioContext.TestError?.Message
});
} else if (this.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.UndefinedStep)
{
currentScenario.Log(new AddLogItemRequest
{
Level = LogLevel.Error,
Time = DateTime.UtcNow,
Text = new MissingStepDefinitionException().Message
});
}

currentScenario.Finish(request);
currentScenario.FinishTask.Wait();

ReportPortalAddin.OnAfterScenarioFinished(this, new TestItemFinishedEventArgs(Bridge.Service, request, currentScenario));
}
Expand Down

0 comments on commit 063cde7

Please sign in to comment.