To create a test report for .NET you will need the following two packages in your project:
β
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.3.41" />
Then you need to make sure you have a default profile file (Default.srprofile
) for SpecFlow with the contents as shown below:
β
<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specflow.org/schemas/plus/TestProfile/1.5">
<Settings projectName="HotelBookingTests" />
<Execution stopAfterFailures="3" testThreadCount="1" testSchedulingMode="Sequential" />
<Report>
<Template name="../../../Templates/CucumberJson.cshtml" outputName="Report.json"/>
</Report>
<TestAssemblyPaths>
<TestAssemblyPath>HotelBookingTests.dll</TestAssemblyPath>
</TestAssemblyPaths>
</TestProfile>
The important thing within the default profile is that you need to specify the template for the report. You can find the JSON template in the NuGet package for the SpecFlowRunner.
To locate the template within, you should unzip the package then you'll be able to find CucumberJson.cshtml
under the templates
directory. You can also find the template in our example project in here.
You will need to create a folder named Templates
in your project, at the same level as the Default.srprofile
file and then put the JSON template inside that folder.
Finally, you can run the test (In Visual Studio: Test -> Run all tests) and it will create the test report as a JSON file. This will also work with .NET Core.
β
After generating the test result you can upload it to Behave Pro/Jira using this guide: https://help.hindsightsoftware.com/en/articles/4301402-publishing-cucumber-test-results-to-jira
You can find our .NET SpecFlow example repository here: https://github.com/hindsightsoftware/hotel-booking-specflow-dotnet-example