An API mocking library for iOS.
-
Drag
output/DDMockiOS/
into project root folder -
Create a new run script to target build phase and add
python ${SRCROOT}/DDMockiOS/init.py <path_to_mock_files_directory>/mockfiles
-
Add
DDMock.shared.initialise()
to AppDelegate -
Add
DDMockProtocol.initialise(config: ...)
to networking library
e.g.
let configuration = URLSessionConfiguration.default
// other configuration set up
DDMockProtocol.initialise(config: configuration)
- Check if after first run of the app, the
Settings.bundle
file underneath theDDMockiOS/
is added to the project. If not add this to the project.
-
Run
sh frameworkMerge.sh DDMockiOS
-
FAT framework should be added in
output/DDMockiOS
-
Follow Getting Started steps
- 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