Allow to output the cucumber.json formatAnswered
I was wondering if it would be possible to generate a report in a JSON format.
Cucumber allow this, through the -f or -p option.
This is the missing piece in using SpecFlow in a complexe project, publishing results on another tool(XRAY), which links JIRA feature to SpecFlow scenarios.
Update: Thanks @matusnovak for sharing a workaround with the community. Follow the steps below:
I am assuming you have the following dependency in your csproj file:
<PackageReference Include="SpecRun.SpecFlow" Version="3.3.41" />
Create a file named
Default.srprofileright next to your csproj file (maybe a root directory of your project) with the following contents:
<?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>Example.dll</TestAssemblyPath> </TestAssemblyPaths> </TestProfile>
This profile specifies that the report shall be created as
To get the template, download the following package: https://www.nuget.org/packages/SpecRun.Runner/ and extract it as a zip file. No need to install it at all, just open with some zip manager, 7-Zip will do just fine.
CucumberJson.cshtmlis in the
templatesfolder within the NuGet package.
You will need to create a folder named
Templatesin your project, right next to your
Default.srprofilefile and put the JSON template in that folder.
That's all. After that all I did was to run the tests (In Visual Studio: Test -> Run all tests) and it created the test report as a JSON file. It should also work with .NET Core.
I don't understand why the JSON template is hidden in such way, why not just provide it within SpecFlow documentation? One does not automatically assume that they need to extract the nuget package.0
Great work Mario Steiner. Let me also share a tutorial for Xray on Jira server/DC that exemplifies precisely this. It's a bit old but I think it's in line with what you shared.0
Will this work with .Net 6???0
Thanks @Mario Steiner
But I am getting conflict here, When I create specflow nunit project by default SpecFlow.NUnit is part of csproj
But you are suggestion to add SpecRun.SpecFlow this makes the conflict and getting build error0
Please sign in to leave a comment.