I have a Nuit Test with Extent Report 4 configured for multiple classes. I am getting the extent report result correctly for the first class but its not reporting the 2nd class status (Only one class is reporting at a time)
Here is the class created for ExtentReprot
namespace ReportTestProject
{
[TestFixture]
public class SetupFixture1
{
public static ExtentReports _extent;
public static ExtentTest _test;
[OneTimeSetUp]
public void StartReport()
{
_extent = new ExtentReports();
var dir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\bin\\Debug", "");
DirectoryInfo di = Directory.CreateDirectory(dir + "\\Test_Execution_Reports");
var htmlReporter = new ExtentHtmlReporter(dir + "\\Test_Execution_Reports" + "\\Automation_Report" + ".html");
_extent.AddSystemInfo("Environment", "DEV");
_extent.AddSystemInfo("User Name", "RAKESH");
_extent.AttachReporter(htmlReporter);
_test = _extent.CreateTest(TestContext.CurrentContext.Test.Name);
}
[TearDown]
public void aftertest()
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stacktrace = "" + TestContext.CurrentContext.Result.StackTrace + "";
var errorMessage = TestContext.CurrentContext.Result.Message;
Status logstatus;
switch (status)
{
case TestStatus.Failed:
logstatus = Status.Fail;
_test.Log(logstatus, "Test " + logstatus + " – " + errorMessage + stacktrace);
break;
default:
logstatus = Status.Pass;
_test.Log(logstatus, "Test " + logstatus);
break;
}
}
[OneTimeTearDown]
public void AfterClass()
{
_extent.Flush();
}
}
}
here is my first class
namespace ReportTestProject
{
[TestFixture]
public class TestClass1 : SetupFixture1
{
[Test]
public void PassTest1()
{
_test = _extent.CreateTest("PassTest1");
var answer = 42;
Assert.That(answer, Is.EqualTo(42), "Some useful error message");
}
[Test]
public void FailTest1()
{
_test = _extent.CreateTest("FailTest1");
var answer = 43;
Assert.That(answer, Is.EqualTo(42), "answer is not 42 so test failed");
}
}
}
And the second class
namespace ReportTestProject
{
[TestFixture]
public class TestClass : SetupFixture1
{
[Test]
public void PassTest2()
{
_test = _extent.CreateTest("PassTest2");
var answer = 42;
Assert.That(answer, Is.EqualTo(42), "Some useful error message");
}
[Test]
public void FailTest2()
{
_test = _extent.CreateTest("FailTest2");
var answer = 43;
Assert.That(answer, Is.EqualTo(42), "answer is not 42 so test failed");
}
}
}
The issue is, Extent report only showing the result from Test Class 1. Please see screenshot below
What I am doing wrong here. Please help