Forum Discussion

skillsoft's avatar
skillsoft
Frequent Contributor
16 years ago
Solved

[SOLVED]Allow wildcards when adding assertion with groovy

Hi,

Is there anyway to set the "Allow Wildcard"  flag programatically when adding an assertion with groovy? Here is the code that I am using to add the assertion:

def static addAssertion(assertionName,requestName,expectedContent,testRunner,log)
   {
try
{
switch (assertionName)
{
case "XPath Match":
def assertion = testRunner.getTestCase().getTestStepByName(requestName).addAssertion("XPath Match")
assertion.name = assertionName
assertion.path = "declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';soapenv:Envelope[1]"
assertion.expectedContent = expectedContent
break;
case "SOAP Response":
def assertion=testRunner.getTestCase().getTestStepByName(requestName).addAssertion("SOAP Response")
assertion.name = "SOAP Response"
break;
default:
log.info ("There is no case for " + assertionName + " in addSimpleAssertion")
break;
}
}
catch (Exception e)
{
throw new Exception( e );
}
   }

}

Thanks,
Mary

6 Replies

  • Are the assertions already defined? Or do you define them elsewhere in the script. If they are defined using the assertion interface, you can just allow wildcards there.

    /Nenad
    http://eviware.com
  • skillsoft's avatar
    skillsoft
    Frequent Contributor
    I'm dynamically removing the testcase, then creating the request and assertion each time I run the testcase, so the assertions are not already defined and I can't use the assertion interface.  Is there anyway to do this through the soapui API?  If not, can this be added in the future?

    Thanks,

    Mary
    • keanesean's avatar
      keanesean
      Occasional Contributor

      Hi, can you give an example of how to do this? I can't find any reference to  setAllowWidlcards(true) anywhere apart from this specific case!

  • skillsoft's avatar
    skillsoft
    Frequent Contributor
    Thanks, that worked!!

    The javadocs for the SoapUI API are a little hard to figure out and google was no help. Also I couldn't find it in this forum.  Thanks for your time.

    Mary