From the time i started using soapUI(both open source & Pro), I was struggling with one very simple though a painful issue. Adding basic assertion (like SOAP response, Not SOAP Fault) in each and every test step (where number of teststep is around 10+) of your TestCase/TestSuite. There may/are few alternatives available which can be used to acheive this, like create few basic assertion in one teststep and then clonse these assertion into other teststeps.
The above mentioned apporach can be used however that also require many click here and there. So i have written few lines of code to automate that part & these code lines can be customized and extended as per your testing needs.
To proceed with just create a new Groovy Test Step and execute that test step once. Please note: i am assuming you already have all the teststep created under a testcase.
/*
@Title : Gr-ooooo-vy 5
@Author : Pradeep Bishnoi
@Description : Add 2 basic assertion (soap & not soap fault) in all teststeps using the Groovy script
*/
import com.eviware.soapui.model.testsuite.Assertable
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(1)
def testCase = testSuite.getTestCaseAt(0)
wsdlTestSteps = testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class ) //test step
def testStepCount = wsdlTestSteps.size()
( 0..< testStepCount).each
{
// SOAP Response Not SOAP Fault
if (!(wsdlTestSteps[it].getAssertionByName("Not SOAP Fault")))
{
wsdlTestSteps[it].addAssertion("Not SOAP Fault")
}
if (!(wsdlTestSteps[it].getAssertionByName("SOAP Response")))
{
wsdlTestSteps[it].addAssertion("SOAP Response")
}
log.info("Assertion created into Teststep :: " + testCase.getTestStepByName(wsdlTestSteps[it].getName()).getName().toString())
}
Do share the same with others & provide your comments on the same, anything.
// Slight formatting/editing may be required in the code lines when pasting it into soapUI script editor.
The above mentioned apporach can be used however that also require many click here and there. So i have written few lines of code to automate that part & these code lines can be customized and extended as per your testing needs.
To proceed with just create a new Groovy Test Step and execute that test step once. Please note: i am assuming you already have all the teststep created under a testcase.
/*
@Title : Gr-ooooo-vy 5
@Author : Pradeep Bishnoi
@Description : Add 2 basic assertion (soap & not soap fault) in all teststeps using the Groovy script
*/
import com.eviware.soapui.model.testsuite.Assertable
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(1)
def testCase = testSuite.getTestCaseAt(0)
wsdlTestSteps = testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class ) //test step
def testStepCount = wsdlTestSteps.size()
( 0..< testStepCount).each
{
// SOAP Response Not SOAP Fault
if (!(wsdlTestSteps[it].getAssertionByName("Not SOAP Fault")))
{
wsdlTestSteps[it].addAssertion("Not SOAP Fault")
}
if (!(wsdlTestSteps[it].getAssertionByName("SOAP Response")))
{
wsdlTestSteps[it].addAssertion("SOAP Response")
}
log.info("Assertion created into Teststep :: " + testCase.getTestStepByName(wsdlTestSteps[it].getName()).getName().toString())
}
Do share the same with others & provide your comments on the same, anything.
// Slight formatting/editing may be required in the code lines when pasting it into soapUI script editor.