Forum Discussion

Donovan's avatar
Donovan
Occasional Contributor
11 years ago

Test Step Status

Hello Bears,

I keep reviewing all forum topics and I can't find the appropriate solution. I have a groovy script that gets the list of soap test steps and then saves a file to a given location.

When looping thru my list of test steps I would also like to grab the status of the test step and place it in front of the file name.

Please help

def soapuiRequests = testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep )

def startTime = new Date();
def cur_Time = startTime.getMonth() + "_" + startTime.getDate();
cur_Time = cur_Time + "_" + startTime.getHours() + startTime.getMinutes() +startTime.getSeconds()
def fileName = it.name + "_" + cur_Time

def stepStatus ..........................

I only found the following .....
getLastStatus( stepName )

7 Replies

  • Donovan's avatar
    Donovan
    Occasional Contributor
    I placed the following code in my code and I'm receiving the following error message

    def testStatus = context.testStep.getAssertionStatus(it.name).toString()

    "Can't invoke methods getAssertionStatus() on null object." I'm unsure what going on.

    Thanks
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Well the fact that it is a null object is concerning.

    You should just be putting the testStep object there and not just the name though and that might be your issue.
  • Donovan's avatar
    Donovan
    Occasional Contributor
    Still need help. I can't figure it out.

    Thank you

    //Define the object for the collection of requests in the soapUI test case
    import com.eviware.soapui.model.testsuite.Assertable
    def soapuiRequests = testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep )

    //Groovy Script to loop through each requests in the test case.
    soapuiRequests.each
    {
    //Creating file name using current date and time
    def startTime = new Date();
    def cur_Time = startTime.getMonth() + "_" + startTime.getDate();
    cur_Time = cur_Time + "_" + startTime.getHours() + startTime.getMinutes() +startTime.getSeconds()
    def fileName = it.name + "_" + cur_Time
    def testStatus = context.testStep.getAssertionStatus(it).toString()

    def inputFileRequest = new File("C:/Users/"+ fileName+ "_Request.txt")
    def inputFileResponse = new File("C:/Users/"+ fileName+"_Response.txt")
    //Writing soapUI response to the file
    inputFileResponse.write(context.testCase.getTestStepByName(it.name).getProperty("response").value)
    //messageExchange.getRequestContent("GetMissions 1.1- MissionKey").toString()

    //Writing soapUI request to the file
    inputFileRequest.write(context.testCase.getTestStepByName(it.name).getProperty("rawRequest").value)

    }

    log.info ("Completed Write")
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Since it is using WsdlTestRequestStep you can just use the following code. Sorry, didn't spot this before.

    def testStatus = it.getAssertionStatus();
  • Donovan's avatar
    Donovan
    Occasional Contributor
    That worked great.

    Is WsdlTestRequestStep the way to handle something like this? Looking for the most optimal.
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Performance wise I am not sure. It should be about the same.

    As for what you are trying to do, it most likely would be the most optimal since WsdlTestRequestStep gives a couple extra options that makes coding it a little easier.