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 πŸ™‚

Advertisements
Comments
  1. Deborah says:

    I am new to testing and soapui. I need to know the relationship between groovy and soapui and how to use it to automate the tests. Thanks

    • Hi,
      Relation between groovy and soapui is same as what we have for QTP & VB Script.
      To learn soapui soapui.org is a good resource to start with and for groovy refer groovy.codehaus.org.
      Searching the internet would also help, including this blog πŸ™‚

      {Pradeep Bishnoi}

  2. Rads says:

    Thank you for the great post and great efforts…

  3. hamtchi says:

    nice it’s exactly what i searched for
    Thank’s men

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s