Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
December 9, 2016

Extent Reports Log Generation – CSharp





Extent Reports Log Generation will discuss about how to generate log steps in the Extent Reports. While running the test suite user want to log some information about the execution in the report. This information will help the user to understand the test step execution flow and any failures during the test suite execution.

By using Extent Reports we can generate logs in the HTML report. For this we need use the Log() method of the ExtentTest Class. By using this method not only log the step information, we can provide the Pass, Fail and Skip information of the particular test case. To log the information we need to use the LogStatus.Info as first parameter in the Log() method. And we need to use LogStatus.Pass for the passed test case and LogStatus.Fail for the failed test cases.

Below is the sample program for generating step logs in the report:

using NUnit.Framework;
using RelevantCodes.ExtentReports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExtentReportsDemo
{
    [TestFixture]
    public class CreatingStepLogs
    {
        public ExtentReports extent;
        public ExtentTest test;

        [OneTimeSetUp]
        public void StartReport()
        {
            string path = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
            string actualPath = path.Substring(0, path.LastIndexOf("bin"));
            string projectPath = new Uri(actualPath).LocalPath;
            string reportPath = projectPath + "Reports\\ExtentStepLogs.html";
            extent = new ExtentReports(reportPath, true);
        }

        [Test]
        public void StepLogsGeneration()
        {
            test = extent.StartTest("StepLogsGeneration");
            test.Log(LogStatus.Info, "StartTest() method will return the Extent Test object ");
            test.Log(LogStatus.Info, "I am in actual test method");
            test.Log(LogStatus.Info, "We Can Write The Actual Test Logic In This Test");
        }

        [OneTimeTearDown]
        public void TearDown()
        {
            extent.EndTest(test);
            test.Log(LogStatus.Info, "EndTest() method will stop capturing information about the test log");
            extent.Flush();
            test.Log(LogStatus.Info, "Flush() method of ExtentReports wil push/write everything to the document");
            test.Log(LogStatus.Info, "Close() method will clear/close all resource of the ExtentReports object");
            extent.Close();
        }
    }
}

In the above program we have written so many test.Log methods to log the information into the extent reports. This information will logged in the report with time stamp.




Below is the output/report of the above program:

Extent Reports Log Generation
Please watch the YouTube video of this blog for better understanding.



Share this post: on Twitter on Facebook

Generating Extent Reports – CSharp Capture Screenshot in Extent Reports – CSharp

Related Posts

CAPTURE SCREENSHOTS IN EXTENT REPORTS - CSharp

Extents Reports - C#

Capture Screenshot in Extent Reports – CSharp

GENERATING EXTENT REPORTS CSharp

Extents Reports - C#

Generating Extent Reports – CSharp

EXTENT REPORTS INTRODUCTION CSharp

Extents Reports - C#

Extent Reports Introduction – CSharp

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2025