ttutisani / Xunit.Gherkin.Quick

BDD in .NET Core - using Xunit and Gherkin (compatible with both .NET Core and .NET)
MIT License
205 stars 29 forks source link

Scenario name in spec constructor #139

Open alastair-todd opened 2 years ago

alastair-todd commented 2 years ago

Hey

Is there a way to infer the current scenario in the Test class constructor?

I'd like to log this to console so it can be sent to our central logs.


protected AbstractSpecification(SpecificationFixture fixture, ITestOutputHelper testOutput)
        {
            Fixture = fixture;

            LogInformation("Starting..."); // << Scenario title here

Thanks

p.s. Being able to redirect the built-in step logging would also be awesome

I am trying hard to diagnose a stalling in test circleci ...
ttutisani commented 2 years ago

No, the framework currently does not support detecting which scenario is running.

Theoretically, you can write code inside your test methods to determine the scenario name, but you will have to do it in every test method.

ttutisani commented 1 year ago

@alastair-todd did you find a solution to this question? If not, I'll keep this open until you respond or until it's implemented.