With pip as usual.
$ pip install lettuce
You can change the extension to .feature, but it feels better to write it in the features directory. It seems that it also supports Japanese.
features/example.feature
Feature: a cookie in a bug
In order to eat a cookie
I carry a bug
Scenario: simple test
Given I have a bug
Then a cookie exists in the bug
So, when you run lettuce, it will show you a template of the steps you need to write.
python
#You can implement step definitions for undefined steps with these snippets:
# -*- coding: utf-8 -*-
from lettuce import step
@step(u'Given I have a bug')
def given_i_have_a_bug(step):
assert False, 'This step must be implemented'
@step(u'Then a coookie exists in the bug')
def then_a_cookie_exists_in_the_bug(step):
assert False, 'This step must be implemented'
Is there no pending ...?
Create it with .py in the same directory as the feature you created. First of all, copy.
features/example.py
# -*- coding: utf-8 -*-
from lettuce import step
@step(u'Given I have a bug')
def given_i_have_a_bug(step):
assert False, 'This step must be implemented'
@step(u'Then a coookie exists in the bug')
def then_a_coookie_exists_in_the_bug(step):
assert False, 'This step must be implemented'
If nothing is done, everything will fail, so rewrite it like that.
example.py
# -*- coding: utf-8 -*-
from lettuce import *
import sys
import bug #I will make it from now on
@step(u'Given I have a (.*)$')
def given_i_have_a_bug(step, arg):
cls = getattr(sys.modules[arg], arg[0].upper() + arg[1:])
world.__dict__[arg] = cls()
assert world.__dict__[arg], arg + ' must be an instance'
@step(u'Then a cookie exists in the (.*)$')
def then_a_coookie_exists_in_the_bug(step, obj):
assert world.__dict__[obj].cookie, arg1 + ' should return True'
Just run lettuce.
It's a little too shabby. .. ..
bug.py
class Bug(object):
def __init__(self):
self.cookie = True
Recommended Posts