首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >黄瓜进行JUnit试验后的JUnit

黄瓜进行JUnit试验后的JUnit
EN

Stack Overflow用户
提问于 2015-03-02 10:23:33
回答 1查看 3.8K关注 0票数 2

我正在使用Intellij IDEA。我在项目中编写了2个java类和1个特性黄瓜文件。特征结构是:

代码语言:javascript
复制
Feature: First test
  with Cucumber

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

此外,我还用jUnit为RunTest编写了一个Cucumber.class java类:

代码语言:javascript
复制
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 {
}

这是我的测试课的签名,给出了黄瓜,时间和时间:

代码语言:javascript
复制
   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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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放置在项目构建路径中,然后尝试执行

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28807402

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档