Skip to content

nattb8/ddmock-ios

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 56.3%
  • Ruby 30.5%
  • Shell 10.3%
  • Objective-C 2.9%