Forum Discussion
Sachin_Sawe
17 years agoContributor
Hi Ole,
Thank you for your response. However, it does not work as I expect it to. Here is what I am trying to do:
I have the following code in a assertion type "script assertion" by the name "XYZAssert" that is added onto a "MyRequest" WSDL Request Step.
--- script begins ---
< some code here that gets xml holder for request and response >
< some code here that actually asserts myxpath1 and myxpath2 programmatically >
< code below is execucted at the end of the script >
//Add script assertions to be covered in test coverage programmatically
def container = context.getProperty( com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY )
def scriptAssertion = messageExchange.request.getAssertionByName( "XYZAssert" )
def node = resHolder.getDomNode("//ns1:myxpath1")
def xmlObj = org.apache.xmlbeans.XmlObject.Factory.parse( node )
def assertedXPath1 = new com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathImpl( scriptAssertion, "//ns1:myxpath1", xmlObj)
node = resHolder.getDomNode("//ns1:myxpath2")
xmlObj = org.apache.xmlbeans.XmlObject.Factory.parse( node )
def assertedXPath2 = new com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathImpl( scriptAssertion, "//ns1:myxpath2", xmlObj)
if (container)
{
container.addAssertedXPath( assertedXPath1 )
container.addAssertedXPath( assertedXPath2 )
}
--- script ends ---
now what I expect to see when I run test case having "MyRequest" step and with test coverage enabled is :
MyRequest
--- Request
--- Response
--- MyAssert
In my case for MyAssert it shows 0%. Also for Response it does not show parts of green bar in dark green to show % of elements covered by this script.
I hope now you exactly understand what I am looking for. Thank you for your patience. I look forward to hear back from you.
-Sachin
Thank you for your response. However, it does not work as I expect it to. Here is what I am trying to do:
I have the following code in a assertion type "script assertion" by the name "XYZAssert" that is added onto a "MyRequest" WSDL Request Step.
--- script begins ---
< some code here that gets xml holder for request and response >
< some code here that actually asserts myxpath1 and myxpath2 programmatically >
< code below is execucted at the end of the script >
//Add script assertions to be covered in test coverage programmatically
def container = context.getProperty( com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY )
def scriptAssertion = messageExchange.request.getAssertionByName( "XYZAssert" )
def node = resHolder.getDomNode("//ns1:myxpath1")
def xmlObj = org.apache.xmlbeans.XmlObject.Factory.parse( node )
def assertedXPath1 = new com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathImpl( scriptAssertion, "//ns1:myxpath1", xmlObj)
node = resHolder.getDomNode("//ns1:myxpath2")
xmlObj = org.apache.xmlbeans.XmlObject.Factory.parse( node )
def assertedXPath2 = new com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathImpl( scriptAssertion, "//ns1:myxpath2", xmlObj)
if (container)
{
container.addAssertedXPath( assertedXPath1 )
container.addAssertedXPath( assertedXPath2 )
}
--- script ends ---
now what I expect to see when I run test case having "MyRequest" step and with test coverage enabled is :
MyRequest
--- Request
--- Response
--- MyAssert
In my case for MyAssert it shows 0%. Also for Response it does not show parts of green bar in dark green to show % of elements covered by this script.
I hope now you exactly understand what I am looking for. Thank you for your patience. I look forward to hear back from you.
-Sachin