diff --git a/samples/TestWare.Samples.MongoDB/Hook.cs b/samples/TestWare.Samples.MongoDB/Hook.cs index 742a131..1f81171 100644 --- a/samples/TestWare.Samples.MongoDB/Hook.cs +++ b/samples/TestWare.Samples.MongoDB/Hook.cs @@ -27,7 +27,7 @@ public static void BeforeFeature(FeatureContext featureContext) var tags = featureContext.FeatureInfo.Tags; _lifeCycle.BeginTestSuite(name); - _testReport.CreateFeature(name, tags); + _testReport?.CreateFeature(name, tags); } [AfterFeature] @@ -45,7 +45,7 @@ public void BeforeScenario(FeatureContext featureContext, ScenarioContext scenar var description = scenarioContext.ScenarioInfo.Description ?? ""; var scenarioTags = scenarioContext.ScenarioInfo.Tags; - _testReport.CreateTestCase(name, description, scenarioTags); + _testReport?.CreateTestCase(name, description, scenarioTags); _testContext.WriteLine("----------------------------------------- \r\n"); _testContext.WriteLine($"Feature: {featureContext.FeatureInfo.Title}"); @@ -62,7 +62,7 @@ public void BeforeScenario(FeatureContext featureContext, ScenarioContext scenar [AfterScenario] public void AfterScenario() { - _testReport.SetTestcaseOutcome(_testContext.CurrentTestOutcome); + _testReport?.SetTestcaseOutcome(_testContext.CurrentTestOutcome); _lifeCycle.EndTestCase(); } @@ -77,7 +77,7 @@ public static void BeforeTestRun() public static void AfterTestRun() { _lifeCycle.EndTestExecution(); - _testReport.CreateTestReportFile(); + _testReport?.CreateTestReportFile(); } [BeforeStep] @@ -85,7 +85,7 @@ public void BeforeStep(ScenarioContext scenarioContext) { var name = scenarioContext.CurrentScenarioBlock.ToString(); var description = scenarioContext.StepContext.StepInfo.Text; - _testReport.CreateStep(name, description); + _testReport?.CreateStep(name, description); var stepId = $"{_stepCounter:00} {description}"; _stepCounter++; @@ -100,7 +100,7 @@ public void AfterStep(ScenarioContext scenarioContext) foreach (var evidence in evidencesPath) { - _testReport.AddScreenshotToStep(evidence); + _testReport?.AddScreenshotToStep(evidence); _testContext.AddResultFile(evidence); } }