【发布时间】:2020-09-04 21:24:17
【问题描述】:
我正在尝试通过使用此代码进行黄瓜命令行调用来运行不同的测试
public class RunTest {
public RunTest(String test){
System.out.println("you found me"); System.setProperty("protocol","https");
String[] argv = {"-p", "json:cucumber-report.json", "-g", "Otto.CatalogTests", "classes/"+ test +".feature"};
main(argv);
}
}
但是我收到了这个错误信息:
Exception in thread "main" java.lang.NullPointerException
at io.cucumber.messages.Messages$Meta$Builder.setProtocolVersion(Messages.java:6186)
at io.cucumber.core.runtime.CucumberExecutionContext.emitMeta(CucumberExecutionContext.java:59)
at io.cucumber.core.runtime.CucumberExecutionContext.startTestRun(CucumberExecutionContext.java:47)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:71)
at io.cucumber.core.cli.Main.run(Main.java:76)
at io.cucumber.core.cli.Main.main(Main.java:33)
at Otto.CommandLine.RunTest.<init>(RunTest.java:16)
at Otto.CommandLine.ArgumentHandler.executeArguments(ArgumentHandler.java:63)
at Otto.CommandLine.ArgumentHandler.<init>(ArgumentHandler.java:28)
at Otto.CommandLine.Main.main(Main.java:28)
当您单击此链接时:Messages.java:6186 您会看到以下代码:
public Messages.Meta.Builder setProtocolVersion(String value) {
if (value == null) {
throw new NullPointerException();
} else {
this.protocolVersion_ = value;
this.onChanged();
return this;
}
}
看来我没有设置我的协议版本,我该怎么做?
我尝试了System.setProperty("protocol","https");,但没有奏效,我也不知道哪种协议是最佳实践。
感谢您的所有帮助。
【问题讨论】:
标签: java automated-tests cucumber command-line-arguments