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 {
}
そして、これはキュウリが与えられた私の Test クラスの署名です。
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 を使用する必要があります。