0

In my SpecFlow [AfterScenario] step I am pushing results to TestRails via their api. I would like to publish the list of steps executed in the comments but I do see any way to access that information.

Kim
  • 1,068
  • 13
  • 25

1 Answers1

1

I ended up adding a BeforeStep to record the step info I wanted.

    [BeforeStep()]
    public void RecordStep()
    {
        var stepContext = ScenarioContext.Current.StepContext;
        var scenarioTitle = ScenarioContext.Current.ScenarioInfo.Title;

        List<string> steps;
        if (!this.scenarioSteps.TryGetValue(scenarioTitle, out steps))
        {
            steps = new List<string>();
            this.scenarioSteps[scenarioTitle] = steps;
        }

        steps.Add($"{stepContext.StepInfo.StepDefinitionType} {stepContext.StepInfo.Text}");
    }
Kim
  • 1,068
  • 13
  • 25
  • Thanks for the idea! I ended up changing the 'scenarioSteps' variable scope and including it in the FeatureContext so I could access all this information in a static [AfterFeature] method while executing the tests in parallel – ManoPajaro Jun 16 '20 at 22:07