Table of contents
Gherkin is a language that enables non-technical members of a team to clearly and concisely define the behaviour of a given feature before it's implemented. Behave works beside Gherkin to support this behaviour-driven development style.
Over time, a team may build-up a catalog of steps that, if reused, can cut down the amount time it takes for feature tests to be written. But, how can this catalog of pre-existing steps be exposed to non-technical team members?
Give them access to the source code?
This requires knowledge of where the steps themselves are defined within the source. You need to know where to look, and what you're looking for.
Keep a copy of the steps in another external document (such as Confluence / Google Drive / Dropbox)?
It doesn't take much for this to fall behind the actual step definitions, and it's an additional overhead that needs to be manually managed.
Can't behave already do this?
Yes it can, but remember; these are non-technical staff who are afraid of the terminal (plus, they'll need to be set up with a local development environment).
behave-catalog solves this problem by generating a single, searchable HTML document that shows all step definitions, along with how to use them, grouped by GIVEN, WHEN, THEN (and STEP).
You could automatically generate this document as part of your build-pipeline, and host it to make easily accessible, and crucially, always up-to-date.
behave-catalog
works as a wrapper around behave
. It should be run from the same directory from which you'd usually run behave
.
$ pip install behave-catalog $ behave-catalog
behave-catalog
automatically detect all steps (that are discoverable by behave
), and will create a new directory within the same directory from which behave-catalog
was invoked. Open behave-catalog/index.html
in a browser to view the generated document.
For a full listing of flags/command-line options, use the --help
flag. Some common use-cases are described below.
The default output directory can be overridden as follows:
$ behave-catalog --path=<dir>
You can pass command-line arguments through to behave
by providing a string as follows:
$ behave-catalog --command-args="--tags=tag1,tag2,-tag3"