Java 将Cucumber表实例化为对象时出错
我在将数据表映射到Cucumber中的类型时遇到一些问题。 Cucumber希望Pojo与stepdefs位于同一地点。但是如果它在另一个模块中呢?我将如何进行映射?我可以为我的跑步者添加一条线吗Java 将Cucumber表实例化为对象时出错,java,cucumber,Java,Cucumber,我在将数据表映射到Cucumber中的类型时遇到一些问题。 Cucumber希望Pojo与stepdefs位于同一地点。但是如果它在另一个模块中呢?我将如何进行映射?我可以为我的跑步者添加一条线吗 Given an appointment |poid|advisorCrewId|appointmentType| |1234|036264|wxyz| When blah blah Then blah blah 我用的是一种我已经用过的类型 public class Appoint
Given an appointment
|poid|advisorCrewId|appointmentType|
|1234|036264|wxyz|
When blah blah
Then blah blah
我用的是一种我已经用过的类型
public class Appointment implements Serializable {
private static final long serialVersionUID = -1456832796215683035L;
private Integer poid;
private String advisorCrewId;
private String appointmentType;
public Appointment(Integer poid, String advisorCrewId, String appointmentType) {
this.poid = poid;
this.advisorCrewId = advisorCrewId;
this.appointmentType = appointmentType;
}
public Integer getPoid() {
return poid;
}
public String getAdvisorCrewId() {
return advisorCrewId;
}
public String getAppointmentType() {
return appointmentType;
}
}
但是当我试着像这样在Cucumber中访问它时
@Given("^an appointment$")
public void method_name(List<Appointment> appointments) {
this.appointments = appointments;
poid = appointments.get(0).getPoid();
}
你能举一个小的例子吗?我觉得奇怪的是,您使用的数据类型必须与步骤位于同一位置。只要该类型在类路径上可用,就目前我所能理解的范围而言,它应该可以工作 同时,我们已经了解到xstream包在某些情况下的行为是意外的,它可能会在即将发布的Cucumber版本中被替换 看看你能不能让这个样本发挥作用
如果你能让它工作,将使用的数据类型移动到另一个包中,看看单独移动会破坏它。原来这是maven的问题。它试图实例化一个接口,而不是一个类,这就是它抛出这个问题的原因,所以我不好意思地承认我实际上只是遇到了一个maven问题,Cucumber工作得很好。此时我该怎么办?删除问题?谢谢你的回复!你为其他有类似问题的人保留答案。可以通过编辑来描述Maven的问题。这一切都是关于分享和帮助。
cucumber.runtime.CucumberException: cucumber.deps.com.thoughtworks.xstream.converters.ConversionException: Cannot construct com.blahblah.Appointment