Files

Mock Proxy SDK

Mock proxy SDK allows to control mock proxy server parameters from inside your test.

Supported features:

  1. Single route mock.
  2. Scenario mocking (collection of routes).
  3. Control bandwidth.
  4. Control latency.

Start using

To start using SDK create an instance of MockClient(baseUrl: String):

val mockClient = MockClient(baseUrl)

Here baseUrl can be an atlas environment or the local host URL.

If you run tests locally using emulator use Android localhost baseUrl value from Constants:

public const val EMULATOR_LOCALHOST: String = "http://10.0.2.2:3001/"

MockClient instance creation with pre-defined local host value for Android emulator:

val mockClient = MockClient(EMULATOR_LOCALHOST)

Mock single route

SDK assumes mock files are stored in app or test assets.

Mock single route from app assets:

mockClient.setStaticMockFromAppAssets(routeFilePath)

Mock single route from test assets:

mockClient.setStaticMockFromTestAssets(routeFilePath)

Mock scenario

Mock scenario route from app assets (both app and test assets):

mockClient.setScenarioFromAssets(scenarioFilePath)

Reset scenario from app assets:

mockClient.resetScenarioFromAppAssets(scenarioFilePath)

Reset scenario from test assets:

mockClient.resetScenarioFromTestAssets(scenarioFilePath)

Get, set and reset latency


val latencyInfo = mockClient.getLatency()
mockClient.setLatency(LatencyLevel.HIGH)
mockClient.resetLatency()

Get, set and reset bandwidth

val bandwidth = mockClient.getBandwidth()
mockClient.setBandwidth(BandwidthLimit._4G)
mockClient.resetBandwidth()

Resetting the state (reset all)

mockClient.resetAllMocks()