| 1 |
=========================== |
| 2 |
Comparison With Other Tools |
| 3 |
=========================== |
| 4 |
|
| 5 |
There are other options for doing Gherkin-based BDD in Python. We've listed |
| 6 |
the main ones below and why we feel you're better off using behave. Obviously |
| 7 |
this comes from our point of view and you may disagree. That's cool. We're |
| 8 |
not worried whichever way you go. |
| 9 |
|
| 10 |
This page may be out of date as the projects mentioned will almost certainly |
| 11 |
change over time. If anything on this page is out of date, please contact us. |
| 12 |
|
| 13 |
Cucumber_ |
| 14 |
========= |
| 15 |
|
| 16 |
You can actually use Cucumber to run test code written in Python. It uses |
| 17 |
"rubypython" (dead) to fire up a Python interpreter inside the Ruby process though and |
| 18 |
this can be somewhat brittle. Obviously we prefer to use something written in |
| 19 |
Python but if you've got an existing workflow based around Cucumber and you |
| 20 |
have code in multiple languages, Cucumber may be the one for you. |
| 21 |
|
| 22 |
.. _Cucumber: https://cucumber.io/ |
| 23 |
|
| 24 |
|
| 25 |
Lettuce_ |
| 26 |
======== |
| 27 |
|
| 28 |
:pypi:`lettuce` is similar to behave in that it's a fairly straight port of |
| 29 |
the basic functionality of `Cucumber`_. The main differences with behave are: |
| 30 |
|
| 31 |
* Single decorator for step definitions, ``@step``. |
| 32 |
* The context variable, ``world``, is simply a shared holder of attributes. |
| 33 |
It never gets cleaned up during the run. |
| 34 |
* Hooks are declared using decorators rather than as simple functions. |
| 35 |
* No support for tags. |
| 36 |
* Step definition code files can be anywhere in the feature directory |
| 37 |
hierarchy. |
| 38 |
|
| 39 |
The issues we had with Lettuce that stopped us using it were: |
| 40 |
|
| 41 |
* Lack of tags (which are supported by now, at least since v0.2.20). |
| 42 |
* The hooks functionality was patchy. For instance it was very hard to clean |
| 43 |
up the ``world`` variable between scenario outlines. Behave clears the |
| 44 |
scenario-level context between outlines automatically. |
| 45 |
* Lettuce's handling of stdout would occasionally cause it to crash mid-run in |
| 46 |
such a way that cleanup hooks were never run. |
| 47 |
* Lettuce uses import hackery so .pyc files are left around and the module |
| 48 |
namespace is polluted. |
| 49 |
|
| 50 |
.. _Lettuce: http://lettuce.it/ |
| 51 |
|
| 52 |
Freshen_ |
| 53 |
======== |
| 54 |
|
| 55 |
:pypi:`freshen` is a plugin for :pypi:`nose` that implements a |
| 56 |
Gherkin-style language with Python step definitions. |
| 57 |
The main differences with behave are: |
| 58 |
|
| 59 |
* Operates as a plugin for nose, and is thus tied to the nose runner and its |
| 60 |
output model. |
| 61 |
* Has some additions to its Gherkin syntax allowing it to specify specific step |
| 62 |
definition modules for each feature. |
| 63 |
* Has separate context objects for various levels: ``glc``, ``ftc`` and |
| 64 |
``scc``. These relate to global, feature and scenario levels respectively. |
| 65 |
|
| 66 |
The issues we had with Freshen that stopped us using it were: |
| 67 |
|
| 68 |
* The integration with the nose runner made it quite hard to properly debug |
| 69 |
how and why tests were failing. Quite often you'd get a rather cryptic |
| 70 |
message with the actual exception having been swallowed. |
| 71 |
* The feature-specific step includes could lead to specific sets of step |
| 72 |
definitions for each feature despite them warning against doing that. |
| 73 |
* The output being handled by nose meant that you couldn't do cucumber-style |
| 74 |
output without the addition of more plugins. |
| 75 |
* The context variable names are cryptic and moving context data from one |
| 76 |
level to another takes a certain amount of work finding and renaming. The |
| 77 |
behave `context` variable is much more flexible. |
| 78 |
* Step functions must have unique names, even though they're decorated to |
| 79 |
match different strings. |
| 80 |
* As with Lettuce, Freshen uses import hackery so .pyc files are left |
| 81 |
around and the module namespace is polluted. |
| 82 |
* Only Before and no contextual before/after control, thus requiring use of |
| 83 |
atexit for teardown operations and no fine-grained control. |
| 84 |
|
| 85 |
|
| 86 |
.. include:: _common_extlinks.rst |