extentreports-csharp icon indicating copy to clipboard operation
extentreports-csharp copied to clipboard

Extent Report generated name is not customizable in latest 4.1.0

Open vishnuprakash9845 opened this issue 4 years ago • 3 comments

Currently using the 4.1.0 version of Extent Report

Create MSTest Class with 2 Test Methods

Added the below code. Extent report is getting generated in the destination folder, but not with the name provided.

Actual: I gave ReportName: Extent.html to get created, but its creating index.html

Expected: It should create the report as per name provided [ Extent.html ]


using System; using System.Threading; using AventStack.ExtentReports; using AventStack.ExtentReports.Reporter; using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AutomationReporting { [TestClass] public class UnitTest1 { //Extent Reports public static ExtentReports _extentReports; public static ExtentTest test;

    public TestContext TestContext { get; set; }

    [ClassInitialize]
    public static void ClassInitialize(TestContext context)
    {
        Console.WriteLine("ClassInitialize");

        string reportPath = "C:\\TestResults" + "\\Reports\\Extent.html";

        
        ExtentHtmlReporter _extentHtmlReporter = new ExtentHtmlReporter(reportPath);
        _extentHtmlReporter.Config.ReportName = "Extent.html";
        _extentReports = new ExtentReports();
        _extentReports.AttachReporter(_extentHtmlReporter);

        _extentReports.AddSystemInfo("Environment", "Dev");
        _extentReports.AddSystemInfo("Tester", "Vishnu");
        _extentReports.AddSystemInfo("Machine", "Local Laptop");
    }

    [TestInitialize]
    public void TestSetUp()
    {
       
        test = _extentReports.CreateTest(TestContext.TestName);
        test.Log(Status.Info, TestContext.TestName + " test started");
    }

    [TestMethod]
    public void Adding()
    {
        test.Log(Status.Info, "StepLogsGeneration-1");
       

        int a = 1;
        int b = 2;

        Assert.AreEqual(3, a + b, "Addition is failing");

        Thread.Sleep(1000);
    }

    [TestMethod]
    public void Subtracting()
    {
        test.Log(Status.Info, "StepLogsGeneration-2");

        int a = 1;
        int b = 2;

        Assert.AreEqual(1, a - b, "Subtraction is failing");

        Thread.Sleep(1000);
    }


    [TestCleanup]
    public void TestCleanUp()
    {
        if (TestContext.CurrentTestOutcome.ToString() == "Passed")
        {
            test.Log(Status.Info, TestContext.TestName + " test Finished");
        }
        else
        {
            test.Fail(TestContext.TestName + " test Finished");
        }
    }

    [ClassCleanup]
    public static void ClassCleanup()
    {
        _extentReports.Flush();
    }
}

}


In the destination folder this is what its creating

image

Its a small issue, but if its fixed it would be a great product to continue.

vishnuprakash9845 avatar Jun 10 '21 16:06 vishnuprakash9845

@ZimM-LostPolygon @anshooarora can you please help me on the above issue.

vishnuprakash9845 avatar Jun 13 '21 09:06 vishnuprakash9845

This is a bug currently in the newest version of extent reports..

If you use ExtentV3HtmlReporter then it works, like in this example: var htmlreporter = new ExtentV3HtmlReporter(ExtentReportPath + "Data" + DateTime.Now.ToString("MMM-dd-yyyy hh-mm-ss") + ".html");

But Visual Studio will give you a warning that ExtentV3HtmlReporter is outdated.

The newest one is called ExtentHtmlReporter without the V3. But with this one, the output files name is always "index.html"

Just add the V3 to your example code, then it will work. Im curious if this nuget package ever will be fixed tho.

xBeardy avatar Oct 13 '21 11:10 xBeardy

Do we have an update when this will be fixed?

imhighyat avatar Jun 07 '23 19:06 imhighyat