Extraiga el valor que contiene una línea de un archivo de texto usando groovy
Quiero extraer un valor de token en una línea de un archivo de texto.
La línea del archivo de texto es:
<response>{"timestamp": "2013-11-12T14:55:43Z", "data": {"profile": null, "ticket": "f644231-6d46-44c7-add6-de3a4422871e", </response>
archivo maravilloso es:
// read the file from path
def file = new File('c:/tmp/response.txt')
// for example read line by line
def data= file.eachLine { line ->
// check if the line contains your data
if(line.contains('"ticket":')){
return line
}
}
testRunner.testCase.testSuite.project.setPropertyValue('ticket',data)
Entonces, aquí no está almacenando ningún valor en mi boleto variable. Cualquier ayuda, por favor