Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vishnuprakash9845 opened this issue Jun 10, 2021 · 3 comments
Open

Comments

@vishnuprakash9845
Copy link

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
Copy link
Author

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

@xBeardy
Copy link

xBeardy commented Oct 13, 2021

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
Copy link

Do we have an update when this will be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants