13 years ago
Scripting Message Content Assertion
I'm trying to modify a Message Content Assertion dynamically in a groovy script.
Assume I have a testcase with two test steps:
1. Groovy Script
2. SOAP call
The SOAP call has one Message Content Assertion. Now I try to dynamically change the first value of the assertion in the Groovy script:
The value is changed in the xml file, but the testcase won't fail, when I try to run it.
With an XPath assertion I can easily get it to work, but then I'm forced to have a lot of XPath assertions, which increases the risk, that I forget to test some fields.
Assume I have a testcase with two test steps:
1. Groovy Script
2. SOAP call
The SOAP call has one Message Content Assertion. Now I try to dynamically change the first value of the assertion in the Groovy script:
wsdlTestSteps = testRunner.testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class );
wsdlTestSteps.each {
def assertion = it.getAssertionByName("Message Content Assertion");
if (assertion) {
assertion.getConfiguration().getElementsArray(0).setExpectedValue('some value')
}
}
The value is changed in the xml file, but the testcase won't fail, when I try to run it.
With an XPath assertion I can easily get it to work, but then I'm forced to have a lot of XPath assertions, which increases the risk, that I forget to test some fields.
wsdlTestSteps = testRunner.testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class );
wsdlTestSteps.each {
def assertion = it.getAssertionByName("XPath Match");
if(assertion) {
assertion.setExpectedContent('some content');
}
}