The extent report is only reporting the last test suite that has been run.
I have set up selenium tests with 10 different suits that is run in order. The problem is that the Extent Report is only logging the results of the last suite. I have tried different ways of implementing the report to compile all of the results.
The code structure: BaseSetUp Class - initialze the driver (OneTimeSetUp, SetUp, TearDown, OnetimeTearDown)
Generalmethod calls - inherits from BaseSetUp
PageObject Page - get all Page Objects
TestSuits - Inherits from General methods.
I have the report in the BaseSetUp class like this:
[OneTimeSetUp]
public void Setup()
{
try
{
extent = new ExtentReports();
var dir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\bin\\Debug", "");
var htmlReporter = new ExtentHtmlReporter(dir + "\\Test_Execution_Reports" + "\\Automation_Report" + ".html");
extent.AddSystemInfo("Environment", "Xylect AT");
extent.AddSystemInfo("User Name", "Lucas");
extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
}
catch (Exception e)
{
throw (e);
}}
[SetUp]
public void BeforeTest()
{
try
{
_test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
}
catch (Exception e)
{
throw (e);
}
}
[TearDown]
public void AfterTest()
{
try
{
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;
string screenShotPath = Capture(driver, TestContext.CurrentContext.Test.Name);
_test.Log(logstatus, "Test ended with " + logstatus + " – " + errorMessage);
_test.Log(logstatus, "Snapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));
break;
case TestStatus.Skipped:
logstatus = Status.Skip;
_test.Log(logstatus, "Test ended with " + logstatus);
break;
default:
logstatus = Status.Pass;
_test.Log(logstatus, "Test ended with " + logstatus);
break;
}
}
catch (Exception e)
{
throw (e);
}
}
[OneTimeTearDown]
public void TearDown()
{
try
{
//zip();
//Email();
extent.Flush();
driver.Close();
driver.Quit();
}
catch (Exception e)
{
throw (e);
}
}
Ive seen a couple of methods where the prevous report is added to the "new" created one, but i did not get this to work.
Example of a testcase in one of the testsuites
[TestCase(TestName = "01_LogIn"), Order(1)]
public void LogIn()
{
LogIn();
string loginAssert = HomePage.expLoginName.Text;
Assert.IsTrue(loginAssert.Contains("Hi, " + username + ""), "Login falied");
}
Any ideas on how i should move forward?
Running extent report V4
You just follow this link. I hope it solves your problem.
You must create 3 classes.
BaseFixture.cs
ExtentManager.cs
ExtentTestManager.cs
After that, you can initialize the BaseFixture in every test class.
[TestFixture, Parallelizable(ParallelScope.Fixtures)]
public class MemberLogInOut : BaseFixture