我正在进行以下枚举类
public enum EmployeeType {
PERMANENT("10"),
TEMPORARY("20"),
PART_TIME("30");
private final String employeeTypeId;
EmployeeType(final String employeeTypeId) {
this.employeeTypeId = employeeTypeId;
}
public String getEmployeeTypeId() {
return employeeTypeId;
}
}
尝试使用以下规格
class EmployeeTypeSpec extends Specification {
@Unroll
def "validate emp type"(EmployeeType employeeType) {
expect:
// want to assert each employeeType name() and employeeTypeId here
employeeType.name()
employeeType.employeeTypeId
where:
employeeType << EmployeeType.values()
}
}
在这里,我使用values()方法传递每个枚举值。但不确定如何为每个枚举Assert名称和employeeTypeId?
1条答案
按热度按时间p5fdfcr11#
这样的代码可能比
employeeType << EmployeeType.values()
更有意义: