Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.72 KB

README.md

File metadata and controls

46 lines (30 loc) · 1.72 KB

DD Mock

An API mocking library for iOS.

Getting started

  1. Drag output/DDMockiOS/ into project root folder

  2. Create a new run script to target build phase and add

python ${SRCROOT}/DDMockiOS/init.py <path_to_mock_files_directory>/mockfiles

  1. Add DDMock.shared.initialise() to AppDelegate

  2. Add DDMockProtocol.initialise(config: ...) to networking library

e.g.

let configuration = URLSessionConfiguration.default
// other configuration set up
DDMockProtocol.initialise(config: configuration)
  1. Check if after first run of the app, the Settings.bundle file underneath the DDMockiOS/ is added to the project. If not add this to the project.

Building from scratch

  1. Run sh frameworkMerge.sh DDMockiOS

  2. FAT framework should be added in output/DDMockiOS

  3. Follow Getting Started steps

Mock API files

  • All API mock files must be stored under a directory called /mockfiles.
  • The /mockfiles must be a folder reference and not a group and stored under the Resources folder
  • All API mock files are mapped based on the endpoint path and HTTP method.
  • e.g. login mock response file for endpoint POST BASE_URL/mobile-api/v1/auth/login should be stored under mobile-api/v1/auth/login/post
  • For dynamic endpoint url, create directories with _ and _ for every replacement blocks and parameters
  • e.g. mock files for GET BASE_URL/mobile-api/v1/users/_usersId_ should be stored under mobile-api/v1/users/{usersId}/get
  • see sample
  • All mock files need to be JSON files
  • There can be more than one mock file stored under each endpoint path
  • By default, the first file listed (alphabetically ordered) under each endpoint path is selected as the mock response