Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago

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 place where i can check for error log?

 

Thank you

 

  • 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

     

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Depends on what assertion have been set and how error is thrown in case of user written script assertions. By default soapUI throws error messages.

    By the way, why do you need to access them in the groovy? Where is this groovy script placed? Is it inside the project or running independent groovy script?
  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    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