0

I have a question about external mocking server. My set up is:

  1. I have an API which I want to test
  2. The service internally calls Database , Gateways , payment aggregators whichs have their own URLS
  3. I control the Mock URLS which I can call. But if it is internally initiated how can i mock it without changing my code?

For example I call service

  1. I call Controller of paymentservice which I can mock
  2. What about my controller call java module which makes a call to gateway

I want to mock that gateway not controller. I see all the examples of karate-netty and Proxy . Proxy tracks all the request after host:port but in my case the host will be real host and how proxy will track it ?

Looks like I tried so much but did not get any perfect solution

Peter
  • 4,752
  • 2
  • 20
  • 32
  • I am not able to understand this question - so I request the rest of the karate community to try or suggest edits to the question – Peter Thomas Dec 13 '19 at 04:14

1 Answers1

1

This is not a question regarding karate, because you want to make your code more testable.

Your controller that call other services have to know how to request service. I would expect that you have at leas some sort of configuration file where all the urls and other application properties are specified.

In more complex environment, I would expect some sort of service discovery with consul for instance.

The simplest thing you can do is to read a system or environment property in your controller to make the service url configurable.

Peter
  • 4,752
  • 2
  • 20
  • 32