SpecFlow integration

Specflow by default generates the output results in SpecFlow JSON format. AssertThat plugin can consume it as Cucumber JSON format. The following solution will generate the output result in Cucumber JSON format in parallel and the result could imported to the AssertThat plugin using REST API for Jira Cloud or running a Command line tool.

Option 1 (.NET 4.5)

Step 1: Add Dependencies

https://www.nuget.org/packages/SpecNuts/ https://www.nuget.org/packages/SpecNuts.Json/

Step 2: Add the below code in .cs of feature file

[BeforeTestRun] public static void BeforeTestRun() {     SpecNuts.Reporters.Add(new JsonReporter());       SpecNuts.Reporters.FinishedReport += (sender, args) => {           String pathName = "specflow_cucumber.json";           System.IO.File.WriteAllText(pathName, args.Reporter.WriteToString());           Console.WriteLine("Result File: " + System.IO.Directory.GetCurrentDirectory().ToString() + System.IO.Path.DirectorySeparatorChar + pathName);       }; }

Step 3: Open Text Explorer in Visual Studio by Test > Windows > Test Explorer -> Choose Run All

Step 4: In Visual Studio console, select show output from Test and open Report File as path given in Console

Step 5: The generated output result file will be in Cucumber JSON format with the name "specflow_cucumber.json". The generated JSON can be imported into the plugin now.

Option 2

  • Install SpecFlow and the SpecFlow+ Runner 1.7.2 or newer along with the msbuild helper package; If you're using Visual Studio, just go to NuGet's Console  (Tools | NuGet Package Manager | Package Manager Console)

    • Install-Package SpecRun.SpecFlow

    • Install-Package SpecRun.SpecRun

    • Install-Package SpecFlow.Tools.MsBuild.Generation

      packages.config 

      <?xml version="1.0" encoding="utf-8"?> <packages>   <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />   <package id="SpecFlow" version="2.3.2" targetFramework="net452" />   <package id="SpecFlow.Tools.MsBuild.Generation" version="2.3.2" targetFramework="net452" />   <package id="SpecRun.Runner" version="1.7.2" targetFramework="net452" />   <package id="SpecRun.SpecFlow" version="1.7.2" targetFramework="net452" />   <package id="SpecRun.SpecFlow.2-3-0" version="1.7.2" targetFramework="net452" />   <package id="System.ValueTuple" version="4.3.0" targetFramework="net452" /> </packages>
  • Use the CucumberJson.cshtml report template provided in this page

Before compiling and running the tests, you have to use a proper SpecFlow report template file in order to generate a valid Cucumber JSON report and you have to configure the test profile to use it.

CucumberJson.cshtml 

Default.srprofile 

 

Tests can be run from within the IDE (e.g. Visual Studio) or by the command line; in the later case, make sure to specify the profile name and all the paths properly.

Since there is code-behind file generation, it is required to have the NuGet "SpecFlow.Tools.MsBuild.Generation" package.