Thursday, June 02, 2011

Groovy 6 - clone test step assertion using Groovy script in soapUI

Yesterday, I found one interesting question in eviware forum [thread] : seeking the information about replicating the "Clone Assertion" feature from soapUI Pro into the soapUI open source using the groovy. So i thought of trying my hand on the same and shared below is the working piece of code to achieve the same.

P.S. : I have also updated the eviware forum thread and people who 'hates' blog can read the solution in the thread. And thanks to the user for raising this question in forum :-)

Initialize:
# Create 2 property at testcase level named "sourceTestStep" & "targetTestStep" respectively.
# Always copy and paste the name of teststep when update the value of newly defined property, so as to reduce the possibility of TYPO error.
# Create a groovy test step then paste the below code and run the test step. Done!

/*  
@Title : Gr-oooooo-vy 6
@Author : Pradeep Bishnoi
@Description : Clone all the assertion from TestStep [SourceTestStep proptery] into the target TestSTep [TargetTestStep property] by executing a groovy 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 sourceTestStep = context.expand( '${#TestCase#SourceTestStep}' )
def targetTestStep = context.expand( '${#TestCase#TargetTestStep}' )

def testStepSrc = testCase.getTestStepByName(sourceTestStep)
def testStepTrgt = testCase.getTestStepByName(targetTestStep)
def counter = testStepSrc.getAssertionList().size()
for (count in 0..<counter)
{
    testStepTrgt.cloneAssertion(testStepSrc.getAssertionAt(count), testStepSrc.getAssertionAt(count).getName())
}

2 comments:

  1. This is really fascinating, You're an excessively professional blogger. I've joined your feed and stay up for searching
    for extra of your fantastic post. Additionally, I've shared your website in my social networks

    My weblog: Bodybuilding

    ReplyDelete
  2. I drop a leave a response each time I especially enjoy a article on a site or
    if I have something to contribute to the conversation. It's triggered by the sincerness communicated in the post I browsed. And after this article "Groovy 6 - clone test step assertion using Groovy script in soapUI". I was excited enough to drop a thought :) I actually do have a few questions for you if it's okay.
    Is it just me or does it look as if like some of the comments come across as if they are left by brain dead individuals?
    :-P And, if you are posting on other online
    sites, I'd like to follow you. Could you list every one of your public sites like your linkedin profile, Facebook page or twitter feed?

    my page :: no2 maximus review

    ReplyDelete