SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.22k stars 752 forks source link

Documentation request: How to use ITestOutputHelper in a BeforeTestRun hook? #2684

Closed Eshva closed 1 year ago

Eshva commented 1 year ago

Product:

What is missing: I can't figure out how to use ITestOutputHelper in a BeforeTestRun hook. Is it possible at all.

My case is: I want to display docker-image name that will be used to start a container to test an application inside it. Something like this:

   [BeforeTestRun]
    public static async Task BuildMockServerAsync(ITestOutputHelper outputHelper)
    {
        var imageName = Environment.GetEnvironmentVariable(TestConstants.ImageNameEnvironmentVariableName);
        if (!string.IsNullOrWhiteSpace(imageName))
        {
            outputHelper.WriteLine("Docker-image '{0}' will be used assigned from outside.", imageName);
            return;
        }

        outputHelper.WriteLine("Docker-image '{0}' will be built and used.", TestConstants.MockServerImageName);
        await new DockerImageBuilder().BuildAsync(
            TestConstants.MockServerImageName,
            TestConstants.MockHttpServerDockerfileFileName);
    }
clrudolphi commented 1 year ago

I am not a user of SpecFlow+Runner, so my experience may not be directly applicable. ymmv But what type(s) of problems are you experiencing?

Within the core SpecFlow project, the output API is the ISpecFlowOutputHelper (not ITestOutputHelper). {this may differ in the +Runner product; I'm simply not familiar with what its called in that product}

The output it generates is present in the TestExecution.json file.

HTH

Eshva commented 1 year ago

I am not a user of SpecFlow+Runner, so my experience may not be directly applicable. ymmv But what type(s) of problems are you experiencing?

Within the core SpecFlow project, the output API is the ISpecFlowOutputHelper (not ITestOutputHelper). {this may differ in the +Runner product; I'm simply not familiar with what its called in that product}

The output it generates is present in the TestExecution.json file.

HTH

Thank you! Seems like it is what I need.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.