Forum Discussion

joooann's avatar
joooann
Occasional Visitor
7 years ago

Get name of current AssertionEntry

Hi!

 

I need to get the name of the currently executing AssertionEntry in an AssertionTestStep.

 

The AssertionEntry is a Script Assertion, and I need to access its name from inside the script.

 

In the attachment [assertionEntry.png], the name is Response should match source    organisationNumber

 

Is this possible? How do I go about this?

 

Thanks!

  • Hi Jo,

     

    You can get the name and status of individual assertions from the Assertion Test Step with the following Groovy script:

    def testStep = testRunner.testCase.getTestStepByName("AssertionTestStepName") 
    def list = testStep.getAssertionEntryList()
    
    for( assertion in list)
    {
    //log.info("Assertion: " + assertion)
    log.info("Assertion Status: " + assertion.status)
    log.info("Assertion Name: " + assertion.getAssertionName() )
    }