我以前已经单独测试过此代码,一旦将其移入我的班级,它就会中断并给我错误。
groovy.lang.MIssingPropertyException:无此类属性:类csvConsume的testRunner
class csvConsume {
static void main(args) {
def mapList = []
File csvFile = new File("test.csv")
csvFile.splitEachLine( /,\s*/ ){ parts ->
def tmpMap = ""
if( '1' == parts[ 2 ] || '2' == parts[2] ) {
tmpMap = [:]
tmpMap.putAt("id", parts[0])
tmpMap.putAt("matchkey", parts[1])
tmpMap.putAt("bureau_type", parts[2])
tmpMap.putAt("create_date", parts[3])
mapList.add(tmpMap)
}
// etc.
//reading with new reader and writing output file.
def responseHolder = testRunner.testCase.testSteps["Request"].testRequest.response.responseContent
def outputFile = "response.csv"
def reader = csvFile.newReader()
new File(outputFile).append(responseHolder)
reader.close()
}
}
}