csspin_python.behave
The behave plugin provides a way to run behave in the context
of spin, which is a great tool for those who want to run acceptance tests
driven by behave.
How to setup the behave plugin?
To use the behave plugin, a project’s spinfile.yaml must at
least contain the following configuration.
spinfile.yaml to leverage behaveplugin_packages:
- csspin_python
plugins:
- csspin_python.behave
python:
version: "3.11.9"
The provisioning of the required virtual environment as well as the plugins
dependencies can be done via the well-known spin provision-task.
The plugin is now ready to use: spin behave --help.
How to run tests against a CE16 instance using the pytest plugin?
Running tests against a CE16 instance requires this to exist. For the
creation of an instance, the csspin_ce.mkinstance plugin can be used. To do
so, we have to define it within the project’s spinfile.yaml (see
documentation of csspin_ce.mkinstance).
spinfile.yaml for testing against a CE16 instanceplugin_packages:
- csspin-ce
- csspin-frontend
- csspin-java
- csspin-python
plugins:
- csspin_ce.mkinstance
- csspin_python.behave
...
With a proper configuration and the mandatory provision, tests can be run by
executing the behave task. Here we explicitly define the DBMS backend to be
“sqlite” while passing the path to the created instance as an argument to the
behave task.
spin provision
spin -p mkinstance.dbms=sqlite mkinstance
spin behave --instance sqlite
How to run the behave plugin in order to collect coverage?
Running tests and collecting coverage using the behave plugin
can’t be easier, since the plugin’s default configuration already contains the
necessary flags and options to do so. For this reason, one just have to pass the
-c or --coverage flag, to run tests and generate coverage reports.
spin behave --coverage
How to debug tests?
Debugging tests executed by the behave plugin using debugpy can be achieved
by passing the --debug option when calling behave. To diverge from the
default configuration used to run debugpy, one can adjust the {debugpy.opts}.
spin behave --debug -i sqlite
As soon as the debugpy server is listening, one can attach to it using the desired IDE or debugger.
behave schema reference
- behave: 'object'
The behave plugin for spin enables running behave tests in the context of spin.
- behave.flaky: 'bool'
Enable or disable flaky tests
- behave.coverage: 'bool'
Collect coverage while running behave.
- behave.cov_report: 'path'
Filepath to store the coverage report.
- behave.cov_config: 'path'
Filepath to the configuration that behave should respect.
- behave.opts: 'list'
Additional options for the behave command.
- behave.tests: 'list'
List of test files or directories to include.
- behave.report: 'object'
Configuration regarding the test report generation.
- behave.report.name: 'path'
Path to write the test report to.
- behave.report.format: 'str'
A valid formatter of behave to use for the test report.
- behave.schema: 'object'
- behave.requires: 'object'
- behave.requires.spin: 'list'
- behave.requires.python: 'list'
- behave._requires: 'list'