Wednesday, June 15, 2011

Groovy 7 - getStatus & getError message of each assertion in a teststep

In one of the blog post, somebody asked me how they can get the status of each individual assertion of a test step. So on my way to office, i managed to comeup with below is the script which will extend (rather append) the existing code written in blog post - "Groovy 6 - clone test step assertion using Groovy script in soapUI".

Please note, that the below provided script can be extended/merged with other script shared. For instance, you can place few code lines from the script and iterate through all the teststep inside a testcase.

Keeping watching/reading this space, soon i will be sharing the blogs on - communicating with JXL API (free Excel API) & interaction with database using the Groovy.

/*
@Title : Gr-ooooooo-vy VII
@Author : Pradeep Bishnoi
@Description : Get the status of each assertion inside a specific test step.
*/

import com.eviware.soapui.model.testsuite.Assertable
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(1)
def testCase = testSuite.getTestCaseAt(0)
def testStepSrc = testCase.getTestStepByName("myTestStepName")
def counter = testStepSrc.getAssertionList().size()

for (count in 0..<counter)
{

log.info("Assertion :" + testStepSrc.getAssertionAt(count).getName() + " :: " + testStepSrc.getAssertionAt(count).getStatus())
error = testStepSrc.getAssertionAt(count).getErrors()
if (error != null)
{
log.info(error[0].getMessage())
}
log.info("---------------------------- Line to seperate each assertion status in logs -----------------")
}

I would appreciate your valuable comments and other relevant inputs.  Keep sharing & be happy :-)

5 comments:

  1. Thanks a lot for the reply!

    I anyways have found a simpler alternative way. It is too nice and too simple. Will share sometime later.

    Keep in touch!

    ReplyDelete
  2. Hi Pradeep,

    One more thing. I have been trying to create subreports in SoapUI Pro. But I'm unable to.

    When i double-click on Project and go to Reporting tab, there i can see that we can add new sub-reports.

    But when i try to configure new subreport and press OK, it'll go nowhere! The dialog doesn't close at all. I don't have any other option but to click Cancel.

    This is irritating me a lot. Please give a try and let me know the solution

    ReplyDelete
  3. Hello my friends! Who are you!?

    ReplyDelete
  4. That was a good article.

    Thanks,
    Pradeep

    ReplyDelete
  5. @Mallikarjun - Looks like you are bent on only getting info and not in sharing the info that you have.
    "Will share sometime later." - I wonder when is "later".

    ReplyDelete