I'm trying to run Cucumber cli from a Windows command line (Windows 10). All good thus far. I can get it to load my *.feature files from the correct place and tell me which methods I need to implement. I've created a class with @Give, @When, @Then notation on the class methods and then compiled my class cleanly.
The .class file sits in a com\\company\\automation\\ subdirectory of the \\bin directory of my Eclipse Project and all the supporting jars sit in C:\\java. I use the following syntax in a .bat file to try to run but Cucumber reports it can't find my methods and prompts me to write these "missing steps".
The command I'm using is:
java -classpath "C:\\java\\*";"C:\\Users\\Mark\\workspace\\Company Automation\\bin\\*" cucumber.api.cli.Main --glue "C:\\Users\\Mark\\workspace\\Company Automation\\bin\\com\\company\\automation" "C:\\Users\\Mark\\workspace\\Company Automation\\Features"
My implementation of the "missing steps" is below:
package com.company.automation;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class CucumberImplementation {
@Given("^I am a visitor$")
public void i_am_a_visitor() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I visit \"([^\"]*)\"$")
public void i_visit(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^there must be a \"([^\"]*)\" element$")
public void there_must_be_a_element(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^the \"([^\"]*)\" element must contain a \"([^\"]*)\" element$")
public void the_element_must_contain_a_element(String arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^the \"([^\"]*)\" element must contain a \"([^\"]*)\" link$")
public void the_element_must_contain_a_link(String arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^there must be a \"([^\"]*)\" element after the \"([^\"]*)\" element$")
public void there_must_be_a_element_after_the_element(String arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
}
I've tried all kinds of different path forms for the --glue option including classpath:com.company.automation, classpath:com.company.automation.CucumberImplementation.class and similar but with backslashes and forwardslashes. It appears that whatever syntax I use for the argument to the --glue option, Cucumber seems to ignore it completely and not even throw a PendingException on the first step. Nor does it complain that the argument to the --glue option is an invalid path if I just put gibberish there.
Using cucumber-core-1.2.4.jar as the base.
Had the same problem.
This is how I solved it (thanks to comments above):
--glue com.test.app
where "com.test.app" is a package of my step definition file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.