Forum Discussion

SIERRA_NEVADA_C_1's avatar
SIERRA_NEVADA_C_1
Occasional Contributor
14 years ago

Assertion Run Twice

I recently notice that all the assertion for each test step run twice in both soapUI Pro 3.6.1 and 4.0. It is very easy to recreate:
1 - Create a dummy SOAP Request using any WSDL
2 - Create a script assertion and add this line: log.info "Run this 1 time"
3 - Run the step (You will notice that there are two instance of "Run this 1 time" in the script log)

This is normally not an issue, but it becomes very noticeable when I start writing a script to check how many time my mock service is hit and clear the mock service request afterward
1 - xxx.getMockRunner().getMockResultCount()
2 - xxx.getMockRunner().clearResults()

I need to check the count because I want to make sure that my mock service only get hit once per request. I log an error when my MockService hit X time(s) where X != 1. Here is a copy of my script assertion:

mockService = messageExchange.modelItem.testCase.testSuite.project.getMockServiceByName("XXXMock")

ServiceHitCount = mockService.getMockRunner().getMockResultCount()
log.info "ServiceHitCount = " + ServiceHitCount
if (ServiceHitCount != 1)
log.error "Error!!!"

def expectedResponse = context.expand( '${RequestParameter#ExpectedResponse}' )
requestContent = mockService.getMockOperationByName("XXX").getMockResponseByName(expectedResponse).getMockResult().getMockRequest().getRequestContent()

messageExchange.modelItem.testCase.testSuite.setPropertyValue("RequestContent", requestContent)

mockService.getMockRunner().clearResults()

Happy Testing,

Danny
  • Hi Danny,

    hmm.. this should not occur when you run the TestCase instead of the TestStep on its own, can you please give that a try?

    regards,

    /Ole
    eviware.com