0

我正在尝试打印作为 CSV 文件中输入的值。当通过 Junit 运行以下代码集并出现错误时。有人可以帮我摆脱这个错误并成功打印值吗

@RunWith(ThucydidesParameterizedRunner.class)
@UseTestDataFrom(value="test-data/simple-data.csv", separator=';')
public class SampleCSVDataDrivenScenario {

private String name;
private String age;
private String address;

public SampleCSVDataDrivenScenario() {
}


@Qualifier
public String getQualifier() {
    return name;
}

@Test
public void data_driven() {

    System.out.println(getName() + "/" + getAge());
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getAge() {
    return age;
}



public void setAge(String age) {
    this.age = age;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}
}

请在下面找到完整的错误日志

java.lang.NoSuchMethodError: 
org.junit.runners.model.FrameworkMethod.getDeclaringClass()Ljava/lang/Class;
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:421)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:55)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:252)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at net.serenitybdd.junit.runners.SerenityParameterizedRunner.run(SerenityParameterizedRunner.java:206)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

在此处输入图像描述

这就是我的 CSV 文件的样子

在此处输入图像描述

4

1 回答 1

1

NoSuchMethodError 通常表示依赖冲突。您可能正在使用不兼容的 JUnit 版本运行测试 - 确保您使用的 JUnit 版本与您正在使用的 Serenity 版本兼容(Serenity 已经使用 JUnit 4.12 构建了一段时间)。

于 2018-10-04T00:02:34.787 回答