Empty step pattern is giving "Cannot find step definition" when specified at the end of a step sentence
See original GitHub issueI am using Python 2.7.10, MacOS Sierra version 10.12.4 and Radish-BDD version 0.4.1
With the feature file of:
Feature: A test feature for issues with tags specified after a scenario outline examples table
A feature description here
Scenario: Fruit Consumption 2
Given I have a appple
When I eat the apple
Then I get lots of fiber
steps.py contents:
from radish import given, when, then
@given('I have a {}')
def my_step(step, fruit):
pass
@when('I {} the {}')
def my_step(step, method, fruit):
pass
@then('I get lots of {}')
def my_setp(step, what):
pass
Then:
Error: Cannot find step definition for step 'Given I have a apple' in tests/stuff/features/stuff.feature:13
Error Oracle says:
There is no step defintion for 'Given I have a apple'.
All steps should be declared in a module located in tests/stuff.
For example you could do:
@step(r"Given I have a apple")
def my_step(step):
raise NotImplementedError("This step is not implemented yet")
A workaround for using empty step patterns is (Adding something like a period or word after the {}):
NOTE: Your scenario sentences in your feature file will require adding the . or word to the end of the sentence also.
@step(r'I have a {}.')
def my_step(step, user):
pass
@when(r'I {} the {}.')
def my_step(step, method, fruit):
pass
@then(r'I get lots of {}.')
def my_step(step, what):
pass
An alternative work-around is to use regexes as such:
import re
from radish import given, when, then
@given(re.compile(r'I have a (.+)'))
def my_step(step, fruit):
pass
@when(re.compile(r'I (.+?) the (.+)'))
def my_step(step, method, fruit):
pass
@then(re.compile(r'I get lots of (.+)'))
def my_step(step, what):
pass
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Step Definitions - Cucumber Documentation
When Cucumber executes a Gherkin step in a scenario, it will look for a matching step definition to execute. To illustrate how this...
Read more >Cucumber: Unable to find step definition - Stack Overflow
It looks like Cucumber isn't finding your step defintion class. In your unit test class you say: glue = {"com.macro.definition"}.
Read more >Step Definition - Cucumber - Tools QA
A Step Definition is a small piece of code with a pattern attached to it or in other words a Step Definition is...
Read more >A Practical Example of Cucumber's Step Definitions in Java
The step annotated with @Then assumes that the former step has been executed before, and it gets the userAlias variable value from the...
Read more >Make your Word documents accessible to people with ...
This topic gives you step-by-step instructions and best practices on how to make your Word ... To find missing alt text, use the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve created an issue in the parse project: https://github.com/r1chardj0n3s/parse/issues/41
Looking at the radish source code. In
matcher.pyI see that this may be a bug in the third-party libraryparse…On second thought, parse looks fine:
However, this gives as interesting outcome:
and
Looks like
search()is giving a weird result,parse()looks correct.