我正在使用Intellij IDEA。我在项目中编写了2个java类和1个特性黄瓜文件。特征结构是:
Feature: First test
with Cucumber
Scenario: Testing
Given file.xml from ext
When take project path
Then run test此外,我还用jUnit为RunTest编写了一个Cucumber.class java类:
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测试,我就捕捉到了这个异常:
gherkin.formatter.model.Scenario.getId()Ljava/lang/String;:java.lang.NoSuchMethodError
我不知道为什么我会看到这个例外。此外,我在例外之前也看到了这一点:
0种情况 0步 0m0.000s
正如我所知道的,如果我将字符串数组作为字符串,Ljava/lang/String会擦除。但在这段代码中,我没有数组。
最新消息。
所以,我找到了这个例外的理由。需要使用gherkin 2.12.2。
发布于 2016-10-05 12:44:05
在上面提供的异常中,gherkin.formatter.model.Scenario.getId()Ljava/lang/String;:java.lang.NoSuchMethodError:
我认为您使用的是gherkin 2.12.0.jar,它在指定的类中没有getId函数
请使用gherkin 2.12.2.jar,并将此jar放置在项目构建路径中,然后尝试执行
https://stackoverflow.com/questions/28807402
复制相似问题