我试图在Spock中做一些数据驱动的测试。
我有一个变量,它依赖于另一个变量:
Services = ["tf1", "fr2"]
Questions(service) = ["What is on {service} ?", "Switch to {service}"]我希望我的测试检查所有可能的服务和问题组合(服务):总共有4个测试。
我试着写了一个这样的where:条款:
where:
service << SERVICES
question << Questions(service)但这在运行时使用groovy.lang.MissingPropertyException: No such property: service for class: com.my.testclass失败。
有人找到解决这个问题的办法了吗?
发布于 2018-01-02 18:50:36
您想要的是不可能的,所有变量都必须具有相同的基数。对于每个service条目,必须有一个对应的question。您在注释中所写的是正确的方法,您可以将其提取到帮助方法where: [service, question] << serviceQuestionsCombinations()中。
https://stackoverflow.com/questions/48064352
复制相似问题