st-pat
8 years agoOccasional Contributor
get testcase status via groovy script
Hi,
I'm fighting with groovy since a week or two (I'm totally new to it and have hardly any knowledge)
I found over all the forums a lot of scripts for groov or teardown or more but all of them seem to miss something so I can't run in inside my Ready/Soap API.
Now I found at https://softwaretestersforum.blogspot.com/2013/03/groovy-script-to-save-test-results-to.html
a working one
import com.eviware.soapui.support.*;
//Get the TestCase Name to use it as a File Name.
def testCase = testRunner.getTestCase()
fileName= testCase.getName()
//Get Current date time stamp to append the same in the file name.
def date = new Date()
def dts = date.format("yyyy-MM-dd-HH-mm-ss")
//Write Request to a XML File and save it with Date Time stamp appended to your filename.
def myXmlRequest = "x:/"+fileName+"Request_"+dts+".xml"
def req1 = context.expand('${brianSisClubQuery - Request#Request}')
def req2 = context.expand('${brianSisClubWrite - Request#Request}')
def req3 = context.expand('${CLUBFOR-Fail#Request}')
def request = req1+req2+req3
def req = new File(myXmlRequest)
req.write(request, "UTF-8")
// Write Response to a XMl File and save it with Date Time stamp appended to your filename.
def myXmlResponse = "x:/groove/"+fileName+"Response_"+dts+".xml"
def resp = context.expand( '${brianSisClubQuery - Request#Response}' )
def resp1 = context.expand( '${brianSisClubWrite - Request#Response}' )
def resp2 = context.expand( '${CLUBFOR-Fail#Response}' )
def response =resp+resp1+resp2
def res = new File(myXmlResponse)
res.write(response, "UTF-8")
the thing is it only takes the testeps (which are ok for that case where there's only 3 but I have like 60 steps in other cases)
if i change it to the Testcase property the file stays empty
import com.eviware.soapui.support.*;
//Get the TestCase Name to use it as a File Name.
def testCase = testRunner.getTestCase()
fileName= testCase.getName()
//Get Current date time stamp to append the same in the file name.
def date = new Date()
def dts = date.format("yyyy-MM-dd-HH-mm-ss")
//Write Request to a XML File and save it with Date Time stamp appended to your filename.
def myXmlRequest = "x:/groove"+fileName+"Request_"+dts+".xml"
def req1 = context.expand('${#CLUB-ATM-UC#Request}')
//def req2 = context.expand('${brianSisClubWrite - Request#Request}')
//def req3 = context.expand('${CLUBFOR-Fail#Request}')
def request = req1 //+req2+req3
def req = new File(myXmlRequest)
req.write(request, "UTF-8")
// Write Response to a XMl File and save it with Date Time stamp appended to your filename.
def myXmlResponse = "x:/groove/"+fileName+"Response_"+dts+".xml"
def resp = context.expand( '${#CLUB-ATM-UCt#Response}' )
//def resp1 = context.expand( '${brianSisClubWrite - Request#Response}' )
//def resp2 = context.expand( '${CLUBFOR-Fail#Response}' )
def response =resp//+resp1+resp2
def res = new File(myXmlResponse)
res.write(response, "UTF-8")so where's my error (maybe only in my brains)..
thnx