我有以下Given
声明:
ServiceSatus.feature:
Given I run a request for service status with the following options
|field1 |field2 |field3 |
|all |1517029200 |5234817 |
StepDefinition.java:
private HashMap<String,String> options = new HashMap<String, String>();
@Given("I run a request for service status with the following options")
public void i_run_a_request_for_service_status(ExamplesTable featureOptions) {
options.put("field1",featureOptions.getRows().get(0).get("field1"));
options.put("field2",featureOptions.getRows().get(0).get("field2"));
options.put("field3",featureOptions.getRows().get(0).get("field3"));
}
Cucumber 将其识别为有效的Examples Table
,但是我收到一个错误,说它不是 Map 或 List 类型。
Cucumber 异常:不是 Map 或 List 类型:class org.jbehave.core.model.ExamplesTable
我的功能文件中是否存在某种类型的语法错误?
编辑: 我在 jUnit 的 rest-assured、bdd-serenity 和 cucumber 之上使用 jBehave ExampleTables。
pom.xml:
依赖项:
<properties>
<serenity.version>1.9.1</serenity.version>
<serenity.maven.version>1.5.8</serenity.maven.version>
<junit.version>4.12</junit.version>
<slf4j.version>1.6.1</slf4j.version>
<maven.failsafe.plugin.version>2.18</maven.failsafe.plugin.version>
<maven.compiler.plugin.version>3.2</maven.compiler.plugin.version>
<serenity.cucumber.version>1.9.1</serenity.cucumber.version>
</properties>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-rest-assured</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>4.1.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
插件:
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>