Lettuce is used as a command line utility, it means that currently the only way to use it is through a shell.
Once in a shell, you can use lettuce in 2 ways:
Which means having the simple features/step_definitions folder somewhere in your project
The difference between them is that within Django you have more options, but both ways have these common options:
user@machine:~/projects/myproj$ lettuce path/to/some/file.feature
With this option, your feature can even be out of the default features
folder.
user@machine:~/projects/myproj$ lettuce path/to/some/file.feature -s 3,5,9
This will run the scenarios 3, 5 and 9 from file
path/to/some/file.feature
Maybe you can find it senseless, but it works like that, and does not hurt so far :)
user@machine:~/projects/myproj$ lettuce -s 3,5,9
Yeah, guess what?
This command will run the scenarios 3, 5 and 9 of all feature files
living on myproj/features
folder.
user@machine:~/projects/myproj$ lettuce --verbosity=1
This is lettuce's minimum verbosity level. It shows dots for each step run, regardless of what scenario or what feature is currently running.
For example, if you have a feature that looks like:
Feature: Manipulate strings
Scenario: Uppercased strings
Given I have the string "lettuce leaves"
When I put it in upper case
Then I see the string is "LETTUCE LEAVES"
The output will be:
user@machine:~/projects/myproj$ lettuce -v 1
...
1 feature (1 passed)
1 scenario (1 passed)
3 steps (3 passed)
user@machine:~/projects/myproj$ lettuce --verbosity=2
In this mode, lettuce will print each scenario name that is currently being ran, followed by OK, FAILED or ERROR depending of the status of the steps within that scenario.
For example, if you have a feature that looks like:
Feature: Manipulate strings
Scenario: Uppercased strings
Given I have the string "lettuce leaves"
When I put it in upper case
Then I see the string is "LETTUCE LEAVES"
Scenario: basic math
Given I sum 2 and 5
Then I see the result is 9
The output will be:
user@machine:~/projects/myproj$ lettuce -v 2
Uppercased strings ... OK
basic math ... FAILED
1 feature (1 passed)
2 scenarios (2 passed)
5 steps (4 passed)
user@machine:~/projects/myproj$ lettuce --verbosity=3
This mode is a lot more verbose than the later one. It prints every single feature, with really useful information like:
For example, let's say you have the feature below, but only the step
Given I have the string "lettuce leaves"
is defined
Feature: Manipulate strings
Scenario: Uppercased strings
Given I have the string "lettuce leaves"
When I put it in upper case
Then I see the string is "LETTUCE LEAVES"
Your output will look like:
user@machine:~/projects/myproj$ lettuce -v 3
Feature: Manipulate strings # features/strings.feature:1
Scenario: Uppercased strings # features/strings.feature:2
Given I have the string "lettuce leaves" # features/step_definitions/example-steps.py:5
When I put it in upper case # features/strings.feature:4 (undefined)
Then I see the string is "LETTUCE LEAVES" # features/strings.feature:5 (undefined)
1 feature (0 passed)
1 scenario (0 passed)
3 steps (2 undefined, 1 passed)
You can implement step definitions for undefined steps with these snippets:
# -*- coding: utf-8 -*-
from lettuce import step
@step(u'When I put it in upper case')
def when_i_put_it_in_upper_case(step):
assert False, 'This step must be implemented'
@step(u'Then I see the string is "(.*)"')
def then_i_see_the_string_is_group1(step, group1):
assert False, 'This step must be implemented'
This mode is almost exactly the same of level 3, the difference is that it's colorful.
user@machine:~/projects/myproj$ lettuce -h
Shows all the options described here.