我正在阅读Cucumber for Java书籍并遇到问题 . 我在cli上收到以下错误:
Exception in thread "main" java.lang.NullPointerException
at java.util.Objects.requireNonNull(Unknown Source)
at java.util.Arrays$ArrayList.<init>(Unknown Source)
at java.util.Arrays.asList(Unknown Source)
at cucumber.runtime.io.FileResourceIterator$FileIterator.<init>(FileResourceIterator.java:50)
at cucumber.runtime.io.FileResourceIterator$FileIterator.next(FileResourceIterator.java:64)
at cucumber.runtime.io.FlatteningIterator.moveToNext(FlatteningIterator.java:29)
at cucumber.runtime.io.FlatteningIterator.moveToNext(FlatteningIterator.java:32)
at cucumber.runtime.io.FlatteningIterator.hasNext(FlatteningIterator.java:57)
at cucumber.runtime.io.FileResourceIterator.hasNext(FileResourceIterator.java:25)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:103)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:239)
at cucumber.runtime.Runtime.run(Runtime.java:111)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
我的cucumber.bat如下;
javac -cp "jars/*" step_definitions/CheckoutSteps.java
java -cp "jars/*;." cucumber.api.cli.Main -p pretty --snippets camelcase \ -g step_definitions features
...和我的CheckoutSteps.java是
package step_definitions;
import cucumber.api.java.en.*;
import cucumber.api.PendingException;
public class CheckoutSteps(){
@Given("^the price of a \"([^\"]*)\" is (\\d+)c$")
public void thePriceOfAIsC(String arg1, int arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I checkout (\\d+) \"([^\"]*)\"$")
public void iCheckout(int arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^the total price should be (\\d+)c$")
public void theTotalPriceShouldBeC(int arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
}
cucumber.bat的第一行似乎编译正常,但我对Excecption感到困惑 . 有任何想法吗?