extent-framework / extentreports-csharp

Extent Reporting Library, .NET
http://extentreports.com
Apache License 2.0
50 stars 40 forks source link

Extent Report generated name is not customizable in latest 4.1.0 #132

Open vishnuprakash9845 opened 3 years ago

vishnuprakash9845 commented 3 years ago

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 commented 3 years ago

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

xBeardy commented 2 years ago

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.

imhighyat commented 1 year ago

Do we have an update when this will be fixed?