Search code examples
python-behave

Behave print all tests to a text file


I have been asked to provide a list of every behave Feature and Scenario we run as part of our regression pack for a document to an external client (not the steps)

As our regression test suite is currently around 50 feature files with at least 10 scenarios in each I would rather not copy and paste manually.

Is there a way to export the Feature name and ID and then the name and ID of each scenario that comes under that feature either to a CSV or text file?

Currently our behave tests are run locally and I am using PyCharm IDE to edit them in.


Solution

  • I have found a roundabout way to do this.

    Set Behave to export to an external txt file using the command outfiles = test_list

    Then use the behave -d command to run my tests as a dry run. This then populates the txt file with the feature, scenario and step of every test. I can export this to Excel and through filtering can isolate the feature and scenario lines removing the steps and then use text to columns to split the feature/scenario description from its test path/name.

    If there is a less roundabout way of doing this it would be good to know as it looks like this is information we will need to be able to provide on a semi regular basis moving forwards.