Skip to main content

[SpecFlow] Logging problems in Feature Hooks

Comments

4 comments

  • Andreas Willich

    We are using the different output APIs of the test runners. So this depends on your used unit test runner and not on SpecFlow.

    What are you using?

    0
  • Kajetan Krawczyk

    Hi. I'm using NUnit. I assumed it's SpecFlows issue because, as I mentioned, the `dotnet test` command does not print anything that happens in Before/AfterFeature. It only prints everything related to Scenario. It doesn't matter if I use the Console.WriteLine to do so, or log4net, or literally any logger.

    Sorry for late response.

    0
  • Andreas Willich

    Ok, I needed to check this. Standard Output handling is not really consistent with VSTest/dotnet test and the different test runners.

    SpecFlow Before/Afterhooks are getting executed via OneTimeSetup/OneTimeTearDown NUnit attributes.

    I used this code:

    [TestFixture]
    public class SuccessTests
    {
        [OneTimeSetUp]
        public void Init()
        {
            Console.WriteLine("CW OneTimeSetup");
            TestContext.WriteLine("TC OneTimeSetup");
        }

        [OneTimeTearDown]
        public void Cleanup()
        {
            Console.WriteLine("CW OneTimeTearDown");
            TestContext.WriteLine("TC OneTimeTearDown");
        }

        [Test]
        public void Add()
        {
            Console.WriteLine("Test");
            TestContext.WriteLine("TC Test");
        }
    }

     

    And I didn't get any output at all:

    Neither Console.Writeline nor TestContext.WriteLine

    If it doesn't work in plain NUnit, we will never get it to work in SpecFlow.

    0
  • Kajetan Krawczyk

    Ha! That explains much then :) Thank you very much for assistance. 

    0

Please sign in to leave a comment.

Powered by Zendesk