skillsoft
15 years agoFrequent Contributor
[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
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
I would recommend starting a new topic rather than resurecting a 9 year old thread, but...
The setAllowWidlcards() method is specified by the AbstractXmlContainsAssertion class. The classes XPathContainsAssertion and XQueryContainsAssertion both extend this abstract class.