Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to generate report using extent reports in Page Object Model in C#

    How to generate report using extent reports in Page Object Model in C#

    May 15, 2024

    I have created a POM framework using NUnit in C#. I have created Reporting.cs file which creates reports for the test in that class. How I can generate reports for all tests in different classes without rewriting the reporting code.

    BaseTest
    – References
    – package
    – config
    – projects
    |- project_name
    |- pages
    |- tests
    |- utils
    |- reporting.cs

    In tests folder files with TestLoginModule.cs have functions

    [Test]
    public void TestFirst()
    {
    // test code
    }
    [Test]
    public void TestSecond()
    {
    // test code
    }

    In tests folder files with TestDashboardModule.cs have functions

    [Test]
    public void TestThird()
    {
    // test code
    }
    [Test]
    public void TestFourth()
    {
    // test code
    }

    In Reporting.cs file

    [OneTimeSetUp]
    public void BeforeClass()
    {
    // create a test report directory and attach reporter
    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.AttachReporter(htmlReporter);
    }

    [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 ended with” + logstatus + “-” + errorMessage);
    test.Log(logstatus, “screenshot”);
    break;
    case TestStatus.Skipped:
    logstatus = Status.Skip;
    break;
    default:
    logstatus = Status.Pass;
    break;
    }

    SB.Driver.Close();
    SB.Driver.Quit();
    }

    [OneTimeTearDown]
    public void AfterClass()
    {
    extent.Flush();
    }

    I want to call Reporting.cs OneTimeSetUp and TearDown after every Test in different files

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleThe CSS stepped value math functions are now in Baseline 2024
    Next Article Switching from inner iFrame to the outter (parent) iFrame

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-2305 – Apache Linux Path Traversal Vulnerability

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Cordless vacuums are going smart, and this Narwal wet/dry vacuum is the latest proof

    Development

    Managing Top-Layer Elements and Display Behavior in CSS

    Web Development

    Microsoft Paint + AI = A Creative Revolution for Everyone

    Development

    The AI Debate: Google’s Guidelines, Meta’s GDPR Dispute, Microsoft’s Recall Backlash

    Development

    Highlights

    Development

    CDK Global Hit by Cyberattack, Backups Potentially Compromised

    June 20, 2024

    CDK Global, a provider of software solutions to auto dealerships across the United States, has…

    CVE-2025-27409 – Joplin Server Path Traversal Vulnerability

    April 30, 2025

    I switched to Mac Studio M4 for two weeks – a Windows PC user’s buying advice

    March 21, 2025

    CVE-2025-4440 – H3C GR-1800AX Buffer Overflow Vulnerability

    May 8, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.