step_definitions folder for global steps

111 views
Skip to first unread message

Steve Fox

unread,
May 26, 2011, 11:57:55 AM5/26/11
to lettuce-d...@googlegroups.com
The documentation at http://lettuce.it/reference/cli.html#reference-cli refers to the ability to define a features/step_definitions folder where you can place .py files to share steps between all your feature files. This works fine when you run all tests (by nature of lettuce looking for all .py files under the current directory rather than code specifically looking for a step_definitions folder, from my read of the code).

Unfortunately, when you specify a path to a feature file, the base path changes to the directory containing that file and the shared steps are not found. Is the features/step_definitions folder expected to be searched regardless of which tests are being run? If so, I will work on a patch as I really need this ability.

Thanks!

Gabriel Falcão

unread,
May 26, 2011, 12:24:41 PM5/26/11
to lettuce-d...@googlegroups.com
Hello Steve!

My buddy Thomas Holloway came out with a nice solution for that,
without needing to change lettuce behaviour.
I found it really nice, and made us keep the project well organized.

The idea is to use "terrain" as a module instead of a single python file.
So imagine a Django project with this package layout:

django_project/
settings.py
manage.py
terrain/
__init__.py
browser.py
steps/
__init__.py
common.py


and on terrain/__init__.py:


from terrain.steps import *
from terrain.browser import *


It's really easy to maintain, plus you take control of where
everything is placed.

I hope it works for you
Best regards,
 -- Gabriel Falcão

2011/5/26 Steve Fox <li...@thefoxhome.net>:

Steve Fox

unread,
May 26, 2011, 12:59:51 PM5/26/11
to lettuce-d...@googlegroups.com
That works great! I hadn't read about terrain yet. Hopefully someone can update the wiki with this info as I'd imagine most people will need this once they have more than a handful of features :)

Gabriel Falcão

unread,
May 26, 2011, 1:35:52 PM5/26/11
to lettuce-d...@googlegroups.com
Yeah, I will add this to the tutorial as soon as I find some spare time.

Best regards and keep hacking, happy hacking :)

 -- Gabriel Falcão

2011/5/26 Steve Fox <li...@thefoxhome.net>:

Reply all
Reply to author
Forward
0 new messages