Forum Discussion

amirse's avatar
amirse
Contributor
7 years ago

Using mocking in SoapUI Pro

I work at a company where we use licensed SoapUI Pro. I have a REST (POST) step in my test case. Now I would like to mock the JSON reply to avoid contacting the real service every time. I don´t have ServiceV but I sin in SoapUI Pro that there is a InsertStep functionality called "REST VirtResponse"
How can I use this one? How do I connect it to my REST (POST) step so that when I run that one the mocked answer will be run?

I also read that this mocking functionalty exist in open source SoapUI. Is that also found in licensed version as well?

Any input regarding this is appriciated.

  • 1.) On the "Projects" Tab of ReadyAPI, you can double-click the WSDL/REST binding, which will allow you to click on the "Endpoints" for that service. There, you can define multiple endpoints to have available in the drop down menu. To make this easier on me, I actually parameterized the endpoint I use to ${#TestSuite#EndPoint} and I store the endpoint value as a custom property at the test suite level. This way, if I ever need to change between a mock and a real service, or different environments, I can adjust that custom level property and have everything change to that. It makes it a lot easier for me.

     

    2.) I am not 100% familiar with virtual services, but I can usually get them all under the same port if I add them all to the same virt. 

     

    3.) SoapUI would need the endpoints defined at the Projects level tab, if I understand this question correctly.

  • groovyguy's avatar
    groovyguy
    Community Hero

    Even though you don't have a Service-V license, you can still use the basic/limited functionality of it to set up a mock service. I have not worked with REST much, but for a SOAP service I typically go to the "Projects" tab, select my SOAP binding, and right click the Request/operation I need to mock a response for. If I select "Add to Virt" it will walk me through setting up a virtual service and editing the response. 

    • amirse's avatar
      amirse
      Contributor

      Hello msiadak,
      Thank you for the reply. It works fine doing the virtualization according to your description. I will change the status to Accepted but before I do so I have three questions which would help newbies like me in future:

      1: Once I have created my  virtual response I change the endpoint in SOAPUI to use the virtual service. But how do I go back to the real endpoint? In SOAPUI now I only have this localhost as an option. Do I need to delete the virtual service just to use the real endpoint? Shouldn´t I be able just to switch endpoints?

      2: In my test I have several steps (POST and GET). Now I created two virtual responses but I cannot use the same port as in the first step since that one is already occupied. The question is, is there another way to put all virtual service steps under the same endpoint or do I need to create one for each service with different ports?

      3: Now I have two new virtual endpoints, ports 8080 and 8082. But the problem is that in SOAPUI GUI I can only select the 8080 endpoint. Is this some kind of limitation since I don´t have ServiceV license?

      • groovyguy's avatar
        groovyguy
        Community Hero

        1.) On the "Projects" Tab of ReadyAPI, you can double-click the WSDL/REST binding, which will allow you to click on the "Endpoints" for that service. There, you can define multiple endpoints to have available in the drop down menu. To make this easier on me, I actually parameterized the endpoint I use to ${#TestSuite#EndPoint} and I store the endpoint value as a custom property at the test suite level. This way, if I ever need to change between a mock and a real service, or different environments, I can adjust that custom level property and have everything change to that. It makes it a lot easier for me.

         

        2.) I am not 100% familiar with virtual services, but I can usually get them all under the same port if I add them all to the same virt. 

         

        3.) SoapUI would need the endpoints defined at the Projects level tab, if I understand this question correctly.