以下是我的CSV文件的示例
A1,B1
A2,B2
A3,B3
这是我的Spock测试:
def testCSV() {
when:
def A = ValueOfA
def B = ValueOfA
then:
println A
println B
where:
ValueOfA | ValueOfA
**get these value from csv file**
}
是否可以读取csv文件并在where子句中传递值?
您可以使用http://groovy-almanac.org/csv-parser-with-groovy-categories/这样的私有方法读取csv文件,然后可以像这样分配变量a和b:
where:
a << [readCSVAMap[0],readCSVAMap[1],readCSVAMap[2]]
b << [readCSVBMap[0],readCSVBMap[1],readCSVBMap[2]]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句