Skip to main content

[SpecFlow+LivingDoc] Readme/Information page

Comments

2 comments

  • Sam Shackleton

    Hi Marek,

    I think that's a great idea and I hope such a feature can be considered for living doc.

    I've considered something similar and tested the following workaround which may suit your needs. One drawback is that the workaround will slightly skew any included test results.

    Basically, we can programmatically add an additional feature file to the root of the living doc.

    To do so:

    1. Generate the livingdoc as you currently are but provide the '--output-type JSON' option to generate a FeatureData.json file rather than LivingDoc.html. The FeatureData.json file contains all of the information for the feature files in your solution.

    2. Modify the FeatureData.json file to add an additional feature file in the 'Features' property at the root of the 'Nodes' property. You can name the feature whatever you like, leave the 'ScenarioDefinitions' value as an empty array, and set the 'Description' to be whatever you want (and can be written in Markdown).

    For example here is how to add a file called 'README' that says 'Hello!":

    "Features": [

                    {

                        "Id": "c2f48dd7-772c-4711-9b1a-9186915e30b2",
                        "ScenarioDefinitions": [],
                        "BackGround": {
                            "Keyword": null,
                            "NodeType": "Background",
                            "Description": null,
                            "Steps": []
                        },
                        "FilePath": null,
                        "RepositoryPath": null,
                        "FileName": "README.feature",
                        "Keyword": "Feature",
                        "NodeType": "Feature",
                        "Title": "README",
                        "Description": "Hello!",
                        "Tags": [],
                        "TitleHash": "2f329543307ebfc1cc54eb5ac1024656"
                    }
                ]
     
    Be sure to change the Id to a random guid, and the title hash to a random string (I'm not sure how the hash is actually calculated).

    3. Use the 'livingdoc feature-data' command to generate the livingdoc html using your modified FeatureData.json file.

    The living doc html file will now include the added file as such:

    You may consider putting all of the above steps in a powershell script.

    I've tested this out and it works for me but if this is approach is ill advised hopefully somebody from the SpecFlow team can chime in. Of course if the JSON schema for the FeatureData.json file changes then changes to the Powershell script may be necessary. Also, I think the JSON file doesn't actually need to be generated and we could directly manipulate the livingdoc html file, but I think generating and modifying the JSON makes the process a bit easier to understand.

    Unfortunately, as you can see from the screenshot, the test results are slightly skewed because the new file defaults to outcome 'Other'. This is also reflected on the Analytics tab.

    1
  • Marek Stąsiek

    Hi Sam,

    Thank you very much for such a nice and fast response!

    Actually that idea you provided is great and we already implemented It. For now It definitely meets our goals and we're able to show all the details we want. Thanks again ;)

    0

Please sign in to leave a comment.

Powered by Zendesk