我试图找出如何在我的步骤定义中从黄瓜功能文件中解析日期字段。
class Person{
String name
LocalDate dob
}
scenario: do something with people
Given list of people:
|name|dob|
| john| 20-09-2001|
@Given("^list of people:")
public void doSomething(List<Person> people) {
}
Run Code Online (Sandbox Code Playgroud)
请注意,我无权访问Person类,我确定自己必须编写自己的转换器或注册某个库中某人编写的转换器,在搜索到的唯一选项后,我看到的是使用@Transform更改它们pojo在java.time.LocalDate字段上。
我目前收到以下异常
cucumber.runtime.CucumberException: cucumber.deps.com.thoughtworks.xstream.converters.ConversionException: Cannot deserialize object with new readObject()/writeObject() methods
---- Debugging information ----
class : java.time.LocalDate
required-type : java.time.LocalDate
converter-type : cucumber.deps.com.thoughtworks.xstream.converters.reflection.SerializableConverter
path : /list/com.pkg.Person/dob
Run Code Online (Sandbox Code Playgroud)
我尝试将dateformat更改为yyyy-MM-dd,通常可以,但在这种情况下不行。我将不胜感激关于如何设置和注册自定义转换器的任何指示
我的黄瓜依赖项如下,如果有任何区别,我可以将其替换为较新版本。
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>2.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)