/ / CucumberでJUnitテストを実行した後のNoSuchMethodError-java、junit4、cucumber-jvm、gherkin、cucumber-junit

キュウリとJUnitテストを実行した後のNoSuchMethodError - java、junit4、cucumber-jvm、gherkin、cucumber-junit

私はIntellij IDEA IDEを使用しています。 プロジェクトで2つのJavaクラスと1つのフィーチャーキュウリファイルを作成しました。機能構造は次のとおりです。

Feature: First test
with Cucumber

Scenario: Testing
Given file.xml from ext
When take project path
Then run test

また、Cucumber.classを使用してRunTestのjUnit javaクラスを1つ作成しました。

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
import org.hamcrest.SelfDescribing;
import gherkin.util.FixJava;
import cucumber.deps.com.thoughtworks.xstream.converters.ConverterRegistry;

@RunWith(Cucumber.class)
public class RunTest {
}

そして、これはキュウリが与えられた私のテストクラスの署名です。

   public class CallSoapSteps {
//variables for file and path to project
String fileXML = "";
String pathToProj = "";
//take any xml file for insert it into Insert() SoapUI step
@Given("^file.xml from ext$")
public String file_xml_from_ext()
{
//take file
return fileXML = "path_to_xml_file";
}
//any statement about our xml file
@When("^take project path$")
public String take_project_path()
{
//take path to project
return  pathToProj = "path_to_soap_project";
}
//any properties for our steps and running SoapTest
@Then("^run test$")
public void run_test() throws Exception {
//add test project
WsdlProject project = new WsdlProject(take_project_path());
//add xml file for test into property
project.setPropertyValue("File", file_xml_from_ext());
//get TestSuite and TestCase by name
TestSuite testSuite = project.getTestSuiteByName("Test");
TestCase testCase = testSuite.getTestCaseByName("Test");
//run test
testCase.run(new PropertiesMap(), false);
}
}

しかし、jUnit Testを実行しようとすると、この例外をキャッチしました。

java.lang.NoSuchMethodError:gherkin.formatter.model.Scenario.getId()Ljava / lang / String;

そして、どのような理由でこの例外が発生するのかわかりません。 また、例外の前にこれが表示されます:

0シナリオ

0ステップ

0m0.000s

私の知る限り、 Ljava/lang/String 文字列として文字列を配列する場合、チェックします。しかし、このコードでは配列がありません。

更新。

だから、私はこの例外の理由を見つけます。 gherkin 2.12.2を使用する必要があります。

回答:

回答№1の場合は3

例外では、上記のjava.lang.NoSuchMethodErrorを提供しました:gherkin.formatter.model.Scenario.getId()Ljava / lang / String;

指定したクラスにgetId関数を持たないgherkin 2.12.0.jarを使用していると思います

gherkin 2.12.2.jarを使用し、このjarをプロジェクトのビルドパスに配置して実行してください