Forum Discussion

Morpheus's avatar
Morpheus
New Contributor
7 years ago

Is there MockResponse for REST/ JSON API?

I want to test incoming request. I want SoapUI to listen on specified port, and when request comes intercept it, and make tests on that requests (schema corectness, contains assertions, etc.). I found MockResponse, but it is only for SOAP application, and I need something for REST concept and JSON calls. Is there any way to do it?

2 Replies

  • JHunt's avatar
    JHunt
    Community Hero

    Why do you say its only for SOAP?

     

    If you have a REST resource in your project, you can right-click and create a REST MockService, and configure it to dispatch MockResponses (com.eviware.soapui.impl.rest.mock.RestMockResponse), the same as you can with SOAP.

     

    Schemas aren't used that often with JSON (there are some offerings out there, but none have enormous popularity). But you can certainly configure your MockService to do assertions on the incoming request. Then it's up to you what you want to happen - should the MockService send an error response, or just log out the problem?:

     

     if (!mockRequest.requestContent.contains('abc')) {
    log.error "Request did not include 'abc': "
    log.error mockRequest.requestContent
    }
    • Morpheus's avatar
      Morpheus
      New Contributor

      Thanks for suggestion about usage of scripts.  Actually, I'm able to handle it using SoapUI groovy scripts and additional command line scripts, but the problems is, I wanted to use power of SoapUI which is Test facilities and automatized report generating. In case of  SOAP, and when we just send request, and check response (we don't wait for request) it is very simple. Is such scripting the only way to fasten testing and report generating?