Discussion:
[Cucumber] Cucumber JAVA: Defining a cucumber step on an overridden method
Anukul Singhal
2018-10-08 20:30:58 UTC
Permalink
Hi,

I am using *cucumber-java 3.0.2 with TestNG and Java 8*, and have the
following query. I have a utility package in one project which I provide
to another cucumber project (which the test engineer uses) as a maven
dependency.

In the utility package, I have defined various wrappers on different
automation tools. Consider the following interface and its implementation
in the utility package:

//Interface:

public interface DatabaseProvider {

public Connection createConnection(String hostName, String username,
String password);
}

//Implementation:

import cucumber.api.java.en.Given;

public class MySQLDatabaseProvider implements DatabaseProvider {

@Override
@Given("^User creates couch database connection with hostname
\"([^\"]*)\" password \"([^\"]*)\" and bucket \"([^\"]*)\"$")
public Connection createConnection(String hostName, String username,
String password) {
//Implementation
...
...
return conn;
end
end

I have wrapped the above implemented definition as a cucumber step, which I
want the user (operating from his cucumber project) to directly be
available from his feature file.

I have succeeded in doing that by adding the glue to point to the utility
package path, which allows the user to directly see this definition.
However, when I execute this from TestNGCucumberRunner, it throws the
following error:

*cucumber.runtime.DuplicateStepDefinitionException: Duplicate step
definitions in createConnection(String,String,String) in
file:/C:/Users/.../<path_to_jar>.jar and
createConnection(String,String,String) in
file:/C:/Users/.../<path_to_jar>.jar*

Even though above two paths are same. If I remove the cucumber step
"@Given("^User creates ...")" from the utility package, and retry the same
test, it works.

Somehow, it does not seem to like when my given cucumber step is part of an
@Override tag, since I have implemented other cucumber steps under the
utility package which are not overridden methods, and they work fine on
invocation from the other cucumber project.

Am I missing anything here, or is there anything wrong? How can I use
cucumber step on an overridden method?

Thanks,
Anukul
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
MP Korstanje
2018-10-09 23:44:31 UTC
Permalink
Would you be able to create a minimal executable example in a github repo and create an issue at cucumber-jvm? This may be a bug.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...