Forum Discussion

MistaWizard's avatar
MistaWizard
Occasional Contributor
10 years ago

compare response of a failed test step to the "contains" assertion and log differences

I've been searching for a way to compare the response of a failed test step to the "contains" assertion of that test step, and spit out just the differences into a log file called that teststepname/label. Sounded so easy :(

In other words, I need a groovy script that's going to sit at the end of the test case and run through all failed test steps inside that testcase then compare each line in the response to each line in the test step assertion contains(its called Contains Assertion which is literally a copy paste of a previous valid and working response) and then we need to spit out the line(s) that are different into a log/file.

  • Cool, i've been working on this non stop and I've got this so far (thanks to everyone for the help)

     

    import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

    def TestCase = testRunner.getTestCase()
    def StepList = TestCase.getTestStepList()

    StepList.each
    {
    if(it.metaClass.hasProperty(it,'assertionStatus'))
    {
    if(it.assertionStatus == AssertionStatus.FAILED)
    {
    log.error "${it.name} " + "${it.assertionStatus}"
    }
    }
    }



7 Replies