线程" main"中的例外情况java.lang.NoSuchMethodError:gherkin.formatter.model.Scenario.getId()Ljava / lang / String;

时间:2017-05-04 05:56:57

标签: cucumber gherkin

我正在编写一个黄瓜代码来自动比较xml文件。但是得到 线程中的异常" main" java.lang.NoSuchMethodError:gherkin.formatter.model.Scenario.getId()Ljava / lang / String;  当我运行功能文件时。我正在使用小黄瓜2.12.2。

我的功能文件

Feature: File Comparator

Scenario Outline: Comparing XML Files

Given I have <XML1> and <XML2> in <Location1> and <Location2>
When I compare <XML1> to <XML2>
Then Both should be the same
Exmaples:

| XML1| location1 | XML2 | location2|

| XML1.xml| C:/Filepath1| XML2.xml| C:/Filepath2|

我的StepDefinition

public class FCStepDefinition {

static Logger log = Logger.getLogger(FCStepDefinition.class);

@Given("^I have ([^\"]*) and ([^\"]*) in ([^\"]*) and ([^\"]*)$")
public static void checkXML1(String xml1, String xml2, String location1, String location2) throws Throwable 
{
    log.info("File name" + xml1 + "and" + xml2 +"from the paths" + location1 + "and" + location2 + "were located");
    System.out.println("File name" + xml1 + "and" + xml2 +"from the paths" + location1 + "and" + location2 + "were located");
}

@When("^I compare ([^\"]*) to ([^\"]*)$")
public static void compareXMLs(String xml1, String location1,String xml2, String location2) throws Exception 
{
    try {
        log.info("Comparing the XML1 to XML2.");
        Assert.assertTrue("\n XML1 is not similar to XML2",XMLComparator.compareXMLs(location1 + xml1, location2 + xml2));
    }

    finally {

    }
}

@Then("^Both should be the same$")
public static void verifyOutput(String expectedSCH, String outputLocation) throws Throwable 
{
    log.info("The Files matches");
}}

我的亚军

package cucumber;

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(

    format = {"pretty", "html:target/html/", "json:target/json/"},
    features = "src/features", 
    strict = true
    )
public class FCRunner {

}

1 个答案:

答案 0 :(得分:0)

你正在某个地方加入早期版本的Gherkin。例如,在Gherkin 2.11.5中,in 2.12.2 it does时该方法尚不存在。

检查你的依赖关系。