question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@Given & @When with same regexp results in error

See original GitHub issue

When I have a @Given and a @When step definition with the same regexp I get a duplicate step definition error.


Example with 1.0.0-RC16:

Scenario: Test duplicate steps Given I do something When I do something

@Given("^I do something$")
public void givenIDoSomething() {
    //Do something
}

@When("^I do something$")
public void whenIDoSomething() {
    //Do something
}

Gives the result:

Exception in thread “main” cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions in Steps.givenIDoSomething() and Steps.whenIDoSomething()


These step definitions should be treated as different due to the @Given & @When annotations, but they are not.

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aslakhellesoycommented, Feb 27, 2012

That’s a feature, not a bug. Cucumber does not distinguish between keywords (Given, When, Then) - only regexen.

0reactions
lock[bot]commented, Oct 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java regular expression: finding match errors - Stack Overflow
My regular expression is fine. It works as it should! The issue is that I want to know more informations in case of...
Read more >
Regex.Matches Method (System.Text.RegularExpressions)
Searches an input string for all occurrences of a regular expression and returns all the matches.
Read more >
re — Regular expression operations — Python 3.11.1 ...
A regular expression (or RE) specifies a set of strings that matches it; the functions in this module let you check if a...
Read more >
Need a regex to find the word "ERROR:", but not match "ERROR
I'm not very good with regex and I can't seem to find the right combination of elements to find errors other than the...
Read more >
A Guide To Java Regular Expressions API - Baeldung
In this tutorial, we'll discuss the Java Regex API, and how we can use regular expressions in the Java programming language.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found