clip_image001 Reports play a fundamental role when it comes to TESTING. Tester can now  know the real-time reports of test suit execution. Reports made ease to know the ratio of Pass? : Fail? post-test suit execution and it is the only documentation to know about test execution results.

Everyone wish to see the detailed description of the test results. Don’t you? here is the solution for it. And, let us see how these reports can be achieved? in Selenium C# - NUnit framework automation testing.

To achieve detailed test execution results as HTML reports we need to rely on third party tool called => Extent Reports. These reports provide decent narration of test execution results and are depicted in PIE chart.

 

 

How to Reference Extent Reports in MS Visual Studio 2015?

Extent Reports can be directly referenced via NuGet Gallery:

1: Reference => Manage NuGet Packages.

clip_image002

2: Install the Extent Reports from NuGet gallery.

clip_image003

3: Extent Reports reference is now added to your project.

clip_image004

How to Initialize Reports?

=> Instance of Extent Reports should be created to initialize the reports.

ExtentReports - Used to generate HTML reports.

ExtentTest – Used to create test log – pass, fail, skip etc…

NamesSpaces: RelevantCodes.ExtentReports;

 

=>clip_image005 Create a folder in the project path/current solution to store the HTML report (execution results).

 

Following is the complete class for extent reports:

 [TestFixture]

 class ExtentReports

 {

       //Instance of extents reports

       public static ExtentReports extent;

       public static ExtentTest test;

             

       [OneTimeSetUp]

       Public void StartReport()

       {

            //To obtain the current solution path/project path

            string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase;

            string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));

            string projectPath = new Uri(actualPath).LocalPath;

 

            //Append the html report file to current project path

            string reportPath = projectPath + "Reports\\TestRunReport.html";

 

            //Boolean value for replacing exisisting report

            extent = new ExtentReports(reportPath, true);

 

            //Add QA system info to html report

            extent.AddSystemInfo("Host Name", "YourHostName")

                .AddSystemInfo("Environment", "YourQAEnvironment")

                .AddSystemInfo("Username", "YourUserName");

 

            //Adding config.xml file

extent.LoadConfig(projectPath + "Extent-Config.xml"); //Get the config.xml file from http://extentreports.com

        }

 [TearDown]

        public void AfterClass()

        {

            //StackTrace details for failed Testcases

            var status = TestContext.CurrentContext.Result.Outcome.Status;

            var stackTrace = "

" + TestContext.CurrentContext.Result.StackTrace + "
";

            var errorMessage = TestContext.CurrentContext.Result.Message;

                       

            if(status == TestStatus.Failed)

            {

                test.Log(LogStatus.Fail, status + errorMessage);

            }

            //End test report

            extent.EndTest(test);

            driver.Quit();           

        }

 

 [OneTimeTearDown]

        public void EndReport()

        {

            //End Report

            extent.Flush();

            extent.Close();

         }

 

Now, let’s see how to create a test method.

Note: The first statement in your test method should be extent reports to start reporting your test method.

Here, I have demonstrated simple Assert test method to create extent reports.

[Test]

public void SampleReporting(string browserName)

{

       //Start Report

       test = extent.StartTest("SampleReporting"); //”SampleReporting” TestMethod name

 

       //Log 'info'

       test.Log(LogStatus.Info, "Sample Reporting demo");

 

       //Pass scenario

       Assert.AreEqual(10,10);

       test.Log(LogStatus.Pass, "Test Passed");

                       

       //Fail scenario

       Assert.IsTrue(false);

           

       test.Log(LogStatus.Fail, "Test Failed");

}

Post running test method, the test execution report looks as shown below:

clip_image006

And, the PIE chart representation of test execution result looks as shown below:

clip_image007

Hope, everyone finds this blog useful for depicting “Text Execution Results”.

Please do subscribe to our blogs and keep yourself updated with the new posts.

 

For more information on extent reports, visit site: http://extentreports.com

 

Happy Reporting smiley

Happy Testing yes

 

canarys-logo

Related

What is Defect? Defect Life Cycle in Software Testing.

Defect is an unexpected behavior of the software application flow against the requirement specificat...

Read More >

What are Frames? How to handle frames in Selenium WebDriver with C#?

IFrame (FullForm: Inline Frame) is an HTML document that is included in another HTML document and is...

Read More >

What is Synchronization? Handling Synchronization in Selenium WebDriver using C#:

Synchronization meaning: when two or more components involved to perform any action, we expect these...

Read More >

Sending Test reports by Email using Office 365, Gmail

Wouldn’t it be great if Test Report are sent automatically across team as soon the Test Execut...

Read More >

Assertions in Coded UI

Let us discuss how to add assertions in coded UI. Assertions are checkpoints/benchmarks to UI c...

Read More >

Analysis of Load Test Results

Analysis of Performance DataAfter you capture and consolidate your results, analyze the captured dat...

Read More >

Parallel Execution using Selenium Webdriver and TestNG

While testing a web application it is very important to test the application on different browsers. ...

Read More >

Handling Radio buttons and Checkboxes using Selenium Webdriver

The main difference between Radio button and Checkbox is that, using radio button we will be able to...

Read More >

Page Object Model

Automation Testing with Selenium using Page Object ModelPage Object Model (POM)Writing selenium scri...

Read More >

Share

Comments

Hi, does ExtenReport supports xUnit framework? I am not able to find this answer clearly from any source available online.Thanks.
10/11/2018 6:17:22 PM | Reply
Hi,I am just wondering if ExtentReport works for xUnit framework or not. Unfortunately, I wasn't able to find the answer any where.Thanks.
10/10/2018 11:14:25 PM | Reply
Hi, I am trying to generate report but report doesn't generate, i am using given code can you please check once and let me know what is the mistake in my codeusing AventStack.ExtentReports;using AventStack.ExtentReports.Reporter;using AventStack.ExtentReports.Reporter.Configuration;using NUnit.Framework;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using TechTalk.SpecFlow;namespace ReportDemoPOC{ public class Start { public static ExtentReports extent; public static ExtentHtmlReporter htmlReporter; public static ExtentTest test; static Start() { if (extent == null) { BasicSetUp(); } } [BeforeScenario] public void Setup() { SeleniumDriver.Intitialize(); SeleniumDriver.Navigate(); test = extent.CreateTest(ScenarioContext.Current.ScenarioInfo.Title); } [AfterScenario] public void TearDown() { if (ScenarioContext.Current.TestError != null) { var error = ScenarioContext.Current.TestError; var errormessage = "" + error.Message + ""; //Add capture screen shot line here extent.AddTestRunnerLogs(errormessage); test.Log(Status.Error, errormessage); test.Fail(errormessage); } SeleniumDriver.Close(); } [OneTimeSetUp] public static void BasicSetUp() { string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase; // string pth = System.IO.Directory.GetCurrentDirectory(); string actualPath = pth.Substring(0, pth.LastIndexOf("bin")); string projectPath = new Uri(actualPath).LocalPath; Console.WriteLine(" -----------Project Path--------------------------------------"); Console.WriteLine(projectPath); // string reportPath = projectPath + "Reports\\" + FeatureContext.Current.FeatureInfo.Title + ".html"; string reportPath = projectPath + "Reports\\TestRunReport.html"; // Console.WriteLine("Report Path is " + reportPath); htmlReporter = new ExtentHtmlReporter(reportPath); htmlReporter.Configuration().Theme = Theme.Dark; htmlReporter.Configuration().DocumentTitle = "SpecFlow Test Resport Document"; htmlReporter.Configuration().ReportName = "Feature Run Results"; extent = new ExtentReports(); extent.AttachReporter(htmlReporter); //extent.LoadConfig(projectPath + "Extent-Config.xml"); } [AfterFeature()] public static void EndReport() { extent.Flush(); } }}
10/4/2018 12:18:04 PM | Reply
Hi, I am trying to generate report but report doesn't generate, i am using given code can you please check once and let me know what is the mistake in my codeusing AventStack.ExtentReports;using AventStack.ExtentReports.Reporter;using AventStack.ExtentReports.Reporter.Configuration;using NUnit.Framework;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using TechTalk.SpecFlow;namespace ReportDemoPOC{ public class Start { public static ExtentReports extent; public static ExtentHtmlReporter htmlReporter; public static ExtentTest test; static Start() { if (extent == null) { BasicSetUp(); } } [BeforeScenario] public void Setup() { SeleniumDriver.Intitialize(); SeleniumDriver.Navigate(); test = extent.CreateTest(ScenarioContext.Current.ScenarioInfo.Title); } [AfterScenario] public void TearDown() { if (ScenarioContext.Current.TestError != null) { var error = ScenarioContext.Current.TestError; var errormessage = "" + error.Message + ""; //Add capture screen shot line here extent.AddTestRunnerLogs(errormessage); test.Log(Status.Error, errormessage); test.Fail(errormessage); } SeleniumDriver.Close(); } [OneTimeSetUp] public static void BasicSetUp() { string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase; // string pth = System.IO.Directory.GetCurrentDirectory(); string actualPath = pth.Substring(0, pth.LastIndexOf("bin")); string projectPath = new Uri(actualPath).LocalPath; Console.WriteLine(" -----------Project Path--------------------------------------"); Console.WriteLine(projectPath); // string reportPath = projectPath + "Reports\\" + FeatureContext.Current.FeatureInfo.Title + ".html"; string reportPath = projectPath + "Reports\\TestRunReport.html"; // Console.WriteLine("Report Path is " + reportPath); htmlReporter = new ExtentHtmlReporter(reportPath); htmlReporter.Configuration().Theme = Theme.Dark; htmlReporter.Configuration().DocumentTitle = "SpecFlow Test Resport Document"; htmlReporter.Configuration().ReportName = "Feature Run Results"; extent = new ExtentReports(); extent.AttachReporter(htmlReporter); //extent.LoadConfig(projectPath + "Extent-Config.xml"); } [AfterFeature()] public static void EndReport() { extent.Flush(); } }}
10/4/2018 11:49:04 AM | Reply
Hi,I am unable to find "RelevantCodes.ExtentReports" DLL in Visual Studio 2015. Does VS 2015 supports this DLL. Please help!
11/21/2017 1:35:42 PM | Reply

Post a Comment

  • Recent
  • Popular
  • Tag
Monthly Archive
Subscribe
Name

Contact Us
  • *
  • *