Forum Discussion
Nullius
13 years agoOccasional Contributor
mkliba wrote: Hi:
Talking about removing/adding/renaming Assertions, you posted before that to remove assertions we can use:
def assertionsList = testRunner.getTestCase().getTestStepByName("Test Request").getAssertionList()
for( e in assertionsList){
testRunner.getTestCase().getTestStepByName("Test Request").removeAssertion(e)
}
Is there any way we can remove the assertion by assertion type and/or assertion name? Ex: Remove all type "XPath Match", or with name "My XPath Match"?
Thanks.
You could use the instanceof operator.
For example, if you want to remove all GroovyScriptAssertions:
def assertionsList = ...
for (e in assertionsList)
{
if (e instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion)
testRunner.getTestCase().getTestStepByName("Test Request").removeAssertion(e)
}
Alls types of assertions:
CrossSiteScriptAssertion, GroovyScriptAssertion, HttpDownloadAllResourcesAssertion, InvalidHttpStatusCodesAssertion, JdbcStatusAssertion, JdbcTimeoutAssertion, JMSStatusAssertion, JMSTimeoutAssertion, NotSoapFaultAssertion, ResponseSLAAssertion, SchemaComplianceAssertion, SensitiveInfoExposureAssertion, SimpleContainsAssertion, SimpleNotContainsAssertion, SoapFaultAssertion, SoapRequestAssertion, SoapResponseAssertion, ValidHttpStatusCodesAssertion, WSARequestAssertion, WSAResponseAssertion, WsdlMessageAssertion, WSSStatusAssertion, XPathContainsAssertion, XQueryContainsAssertion
They all inherit from the TestAssertion interface:
http://www.soapui.org/apidocs/com/eviwa ... rtion.html
(links to all assertion types can also be found on that webpage)
I haven't tried the code I provided, but it should work without any major changes.
Related Content
- 12 years ago
- 3 years ago
Recent Discussions
- 2 days ago