cezarypiatek / NScenario

Dead simple library for annotating steps of test case scenarios.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scenario name resets when using child functions

Osypchuk opened this issue · comments

Readme is a bit obsolete - TestScenario do not exist anymore so maybe I am a bit off.

Provided I am building test scenario using TestScenarioFactory.Default() my expectation is that scenario definition is completed. Thus I am expecting the Name to be defined exactly at this moment.

Consider following example:

public class NScenarioDemo
    {
        [Fact]
        public async Task Main_Test_Function()
        {
            var scenario = TestScenarioFactory.Default();
            var response = await scenario.Step("First step", () => { 
                return new HttpResponseMessage(); });
         
            await HelperFunction(scenario, response);
            await scenario.Step("3rd step", () => { });
        }

        private async Task HelperFunction(ITestScenario scenario, HttpResponseMessage result)
        {
            await scenario.Step("Assert result code valid", () => { });
            await scenario.Step("Assert result content is valid", () => { });
        }
    }

My expected result would be something like:
SCENARIO Main_Test_function
STEP 1 First Step
STEP 2 Assert Result code valid
STEP 3 Assert result content is valid
STEP 4 3rd step

However, the actual result is
SCENARIO Main Test Function

STEP 1: First step
SCENARIO HelperFunction

STEP 1: Assert result code valid
STEP 2: Assert result content is valid
STEP 2: 3rd step

as you see:

  • new scenario added out of the blue
  • nesting is not happening.

Thanks for reporting this issue, I will try to fix it today later. The doc is outdated, sorry for your inconvenience, I need to fix that too.

A new version 3.0.0 with fix for this issue has been just released The DOC in README should be updated. Please let me know if it's working as you expected.

Works perfectly, thanks!