Skip to main content

Allow to output the cucumber.json format

Answered

Comments

2 comments

  • Mario Steiner

    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.srprofile right 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 Report.json with the CucumberJson.cshtml template.

    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.

    The CucumberJson.cshtml is in the templates folder within the NuGet package.

    You will need to create a folder named Templates in your project, right next to your Default.srprofile file 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
  • Sergio Freire

    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

Please sign in to leave a comment.

Powered by Zendesk