Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago
Solved

With groovy how can we get the teststeps status with details when it fails ?

Hi,   with my project i need to know in details which cause errors when a teststep fails. i checked the soapui-error file, it doesn't contains the details about the error. Or is there another...
  • aaronpliu's avatar
    5 years ago

    Hi _ivanovich_ ,

    you can refer to my reply in another topic: https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-use-a-defined-variable-elsewhere-in-a-Groovy-script/m-p/192315#M29615

     

    You did retrieve various running information from test result. I suggest you defined a method to collect running information.

    For instance:

    import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
    
    def testStepDetails(teststep) {
        def request, response, method
        def assertions = [:]  // for assertions
        def propsList = []  // for properties
    
        request = "${teststep.testRequest.getMethod()}  ${teststep.testRequest.response.URL}"
    
        if (teststep.testRequest.assertionStatus == AssertionStatus.FAILED) {
            response = teststep.testRequest.response.contentAsString
            method = teststep.testRequest.method
            teststep.getAssertionList().each {
                assertions[it.getLabel()] = it.getStatus.toString()
            }
            teststep.testCase.getPropertyList().each {propsList << "${it.name}:${it.value}"}

    //return
    return """ Case Properties: ${propsList} \r\n Status: -FAIL- \r\n Request: ${request} \r\n Response: ${response} \r\n Assertions: ${assertions} """ }

    return "" }

     

    Thanks,

    /Aaron