Forum Discussion

VinnyK's avatar
VinnyK
Occasional Contributor
5 years ago

Unable to find Test Logs, not sure if they are being logged

Hi,

 

I am using SpecFlow and Nunit 3 with NUnit3Adaptor.

 

Within my test steps I am logging some test messages and capturing screenthot but I can't find anything in the bin folder nor in the Project directory. I don't even see TestResults folder.

 

LaunchApplication();

IDriver Driver = new LocalDriver();
Driver.Log.Message("Application Launched");
Driver.Log.Screenshot(test.controlGrid, "Screenhot of a Grid table");
Driver.Log.Message("Test Again");
Assert.Fail();// force failing in case the logs are being cleared

 

Am I missing something here ? Can anyone please help me how to use the TestLeft's capturing Test Log and screenshot funtionality?

Thanks in advance

 

 

3 Replies

    • VinnyK's avatar
      VinnyK
      Occasional Contributor

      Thanks Alex, 

       

      I know whats happening, when we add a TestLeft to our project it creates TestFixtureBase with NUnit hook attributes ([OneTimeSetUp], [OneTimeTearDown] ..etc) methods

       

      [OneTimeSetUp]
      public void InitializeFixture()
      {
      _driver.Log.OpenFolder(TestContext.CurrentContext.Test.FullName);
      }

      [OneTimeTearDown]
      public void FinalizeFixture()
      {
      _driver.Log.CloseFolder();
      _driver.Log.Save(TestContext.CurrentContext.TestDirectory + @"\TestResults", Log.Format.Html);
      }

      [SetUp]
      public void TestSetUp()
      {
      _driver.Log.OpenFolder(TestContext.CurrentContext.Test.Name);
      }

      [TearDown]....

       

      When running the NUnit tests, the logging and saving logs, works fine. But when we add SpecFlow on top of this, then these methods with NUnit hook attribute won't get run as SpecFlow has its own hook attributes [BeforeScenario], [BeforeTestRun], [AfterScenario]... etc.

       

      So we would need to replace [OneTimeSetUp] to [BeforeTestRun] and [OneTimeTearDown] to [AfterTestRun] and make the binding methods static and add "[Binding]" on top of the class signature

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        VinnyK :

        Hi,

         

        Thank you for the detailed description. Hope it will help someone else who will use the configuration like yours.