[SpecFlow] Logging problems in Feature Hooks
Hi,
While developing the Jenkins test farm for our test framework (written using SpecFlow), we realized some logging problems. To be precise, all logging that happens in BeforeFeature and AfterFeature hooks is not being printed on the CLI while the test is running. These logs are properly stored in the log files though without any problems, but we'd also like them to be displayed in the CLI. We use the `dotnet` command to run the tests. Only logs related to the Scenario are displayed properly.
I tried the classic Console.WriteLine(), as I thought log4net may be causing that issue, but in the end it was exactly the same.
How do I force SpecFlow to print logs for BeforeFeature properly? Has anyone had that issue before?
Cheers,
Kajetan
-
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 -
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 -
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 -
Ha! That explains much then :) Thank you very much for assistance.
0
Please sign in to leave a comment.
Comments
4 comments