Creating HTML report for test execution result

How to create HTML report with details of test execution Very often , we will be required to create a report with details of test execution , so that it can be presented to various stakeholders. Specflow provides a feature to create HTML reports. Let us look into more details about how is this done Read through and understand details of reporting from specflow. Ensure packages for Specflow, Nunit, Nunit console runner are already installed. If you are using Nunit 3, install NUnit.Extension.NUnitV2ResultWriter package via nuget package manager. If this is not installed, we will get an error “Unknown result format: nunit2”. Follow setups required for running specflow test cases from command line. Details can be found here. Modify the bat file to create nunit2 reports. PathToNunitConsolerunner\nunit3-console.exe --labels=All --out=TestResult.txt "--result=TestResult.xml;format=nunit2" PathTo\AcceptanceTests.dll Add below command into Bat file. This will create HTML Report called “MyResult.html” PathToSpecfloPackage\specflow.exe nunitexecutionreport PathTo\AcceptanceTests.csproj /out:MyResult.html Final bat file will look like below. REM bat file to run test cases from console and create xml result file .\..\..\..\packages\NUnit.ConsoleRunner.3.8.0\tools\nunit3-console.exe --labels=All --out=TestResult.txt "--result=TestResult.xml;format=nunit2" .\AcceptanceTest.dll REM Generate html report from test output .\..\..\..\packages\SpecFlow.2.1.0\tools\specflow.exe nunitexecutionreport .\..\..\AcceptanceTest.csproj /out:MyResult.html EDITED: If it throws below error in newer version of Visual Studio then ensure MS Build tool 2013 is installed. It can be downloaded from https://www.microsoft.com/en-US/download/details.aspx?id=40760 ...

March 5, 2017

Running Specflow Test from command line using Nunit

How to run specflow test cases from command line We can use nunit console runner for running specflow test cases from command line. Running specflow test cases through nunit console runner will help to create test results in xml file, which can then be used for creating html reports. Procedure for command line test execution are Define Nunit as the test runner. This is done in config file <specFlow> <unitTestProvider name="NUnit"/> </specFlow> Include Nunit.Console.Runner package to solution via nuget package manager Run specflow test cases using below command. We can create a bat file with below command and execute them as required. pathToNunitConsoleRunner\nunit3-console.exe PathToProject.dll example will be .\..\..\..\packages\NUnit.ConsoleRunner.3.8.0\tools\nunit3-console.exe .\BDDFramework.dll

March 4, 2017

How to take screenshots with Selenium in C#

Very frequently testers will meet a situation where they need to take screenshot of webpage they are testing , either for base line or as a proof of test result. This is same with automated testing . Even though automated test cases have their own of way of publishing test results, it is always desirable to keep a proof of result.. Screenshot come to help in this regards. In this blog post , I will explain , how to take a screenshot with Selenium Web Driver with C#. In future I will add another couple of post to explain , how to consolidate the screenshots into a PDF document. ...

September 6, 2016 · Aby George A

Element location using XPath Axis

During testing we will sometimes come up to situations where developers are not following best practises for testability . We will frequently come up situations where elements doesn’t have any unique identifiable property. XPath axis comes to help in those situations. We can identify elements using various XPath Properties List of various XPath Axis are available in https://developer.mozilla.org/en-US/docs/Web/XPath/Axes If you have well-defined properties to identify the element, use them as your locator. Please read locator strategy Using XPath and Other Parameters ...

September 3, 2016 · Aby George A

Element Location using XPath

XPath is XML query language which can be used for selecting nodes in XML. Hence it can be used to identify elements from DOM since they are represented as XHTML documents. Selenium WebDriver also supports XPath for locating elements. They also help to look for elements in both direction and hence it is generally slow compared to all other locator strategy. We can use XPath with both absolute path and relative path. ...

August 30, 2016 · Aby George A

Specflow - Sharing data between steps

In Specflow, Step definitions are global. So a scenario can have multiple step definitions which can be present in different classes. Sometimes, there arise a need to share the data between steps residing in different classes. How do we do it?? There are multiple ways to do it Context Injection Feature Context Scenario Context Let us look into more details about how to store and retrieve data using Scenario Context . ...

August 1, 2016 · Aby George A