Forum Discussion

Xardas's avatar
Xardas
New Contributor
5 years ago

How to get assertion info in groovy

Hello,

 

how can i get the assertion data in groovy like the following example:

 

for example the first:

_____

Valid HTTP Status Codes

Status: Failed

Expected; 202

Current: 403

Error Message: Response Status code: 403 is not in acceptable list of status codes

 

_____

or in general:

_____

Name of the assertion

Status: actualStatus

Expected: Expected Value

Current: Current Value

Error Message: Error Message

_____

 

So i need methods for name, status, expectedValue, currentValue and the error message.

 

Thanks for help and answering 🙂

 

  • Xardas :

     

    Hope below code will help you out:

    def assertionsList = testRunner.getTestCase().getTestStepByName("TEST STEP NAME").getAssertionList()
    for( e in assertionsList){
        log.info e.getToken() //gives the value of the content to search for
        log.info e.DESCRIPTION
        log.info e.ID
        log.info e.LABEL
        log.info e.toString()
    }
  • Xardas :

     

    Hope below code will help you out:

    def assertionsList = testRunner.getTestCase().getTestStepByName("TEST STEP NAME").getAssertionList()
    for( e in assertionsList){
        log.info e.getToken() //gives the value of the content to search for
        log.info e.DESCRIPTION
        log.info e.ID
        log.info e.LABEL
        log.info e.toString()
    }