我正在编写一个黄瓜代码来自动比较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 {
}