RESTAssured/Serenity jBehave ExamplesTable 抛出 "Not a Map or List type" 异常
RESTAssured/Serenity jBehave ExamplesTable throwing "Not a Map or List type" exception
我有以下 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 exception: Not a Map or List type: 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>
JBehave 和 Cucumber 模型混合使用:
- J行为:
org.jbehave.core.model.ExamplesTable
- 黄瓜:
cucumber.api.DataTable
这些 class 是类似物,它们代表相同的 class 对象(BDD 表),但属于不同的库。
最好选择一种BDD框架并遵循它的模型。但是,如果在 Cucumber
上下文中仍需要使用 org.jbehave.core.model.ExamplesTable
作为步骤输入参数,则应实现自定义转换器:https://static.javadoc.io/info.cukes/cucumber-core/1.2.5/cucumber/api/Transformer.html
我有以下 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 exception: Not a Map or List type: 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>
JBehave 和 Cucumber 模型混合使用:
- J行为:
org.jbehave.core.model.ExamplesTable
- 黄瓜:
cucumber.api.DataTable
这些 class 是类似物,它们代表相同的 class 对象(BDD 表),但属于不同的库。
最好选择一种BDD框架并遵循它的模型。但是,如果在 Cucumber
上下文中仍需要使用 org.jbehave.core.model.ExamplesTable
作为步骤输入参数,则应实现自定义转换器:https://static.javadoc.io/info.cukes/cucumber-core/1.2.5/cucumber/api/Transformer.html