Forum Discussion

Chris_Osthaus's avatar
Chris_Osthaus
Occasional Contributor
17 years ago

Expecting no request in MockResponse step

I was wondering if anyone has any strategies for verifying the situation where you are expecting your MockResponse step to never receive a request.

Our web service sends out data alerts as requests to clients.  In a normal case, our MockResponse step would receive the alert and perform some basic assertions on it.

We have cases where we want to verify that a client does NOT receive a request.  I have tried using the "Script" portion of the MockResponse step, and examining the mockResponse object for a null value, but it looks like the "Script" only gets executed if the MockResponse step actually receives a request.  I can also fail the MockResponse step by setting the "Timeout" property to an arbitrary value (the MockResponse never receives a request, so it just times out eventually).  However, the test just fails out after the timeout. 

Thanks to anyone who has any ideas!

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    hmm.. try the following:

    1) Set the timeout of the step to the max time to wait
    2) Disable the mockresponse step
    3) create a groovy script step before your mockresponse step containing the following

    def mockResponseStep = testRunner.testCase.testSteps["nameofmockresponseteststep"]
    def result = mockResponseStep.run( testRunner, context )

    // failed means we got a timeout
    assert result.status == com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus.FAILED

    This will run the teststep "manually" and fail if it didn't time out. The step is disabled so it doesn't get executed "normally" after the script finished

    Does this work?

    regards!

    /Ole
    eviware.com
  • I have a similar need to assert that my system does not send a message.

    I like the approach that Ole gives, but the issue that I am running into is that the mock service is not started fast enough.

    I started by trying to create a failing test (where my system "incorrectly" sends a message to the mock service).  I did this by:

    - soapui sends message to my system.  (Receiving this message triggers my system to send out a message to the mock service)
    - soapui groovy script launches mock service step, asserting that a timeout occurs

    It looks like my service attempts to send message to the mock service prior to the mock service actually starting.

    Feature request: option in the mock service to assert that no message was received.