Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justeat/Shock
A HTTP mocking framework written in Swift.
https://github.com/justeat/Shock
Last synced: 2 months ago
JSON representation
A HTTP mocking framework written in Swift.
- Host: GitHub
- URL: https://github.com/justeat/Shock
- Owner: justeat
- License: apache-2.0
- Archived: true
- Created: 2018-06-27T17:33:05.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-01-05T10:56:57.000Z (10 months ago)
- Last Synced: 2024-08-23T04:51:10.794Z (3 months ago)
- Language: Swift
- Homepage: https://www.just-eat.com/
- Size: 340 KB
- Stars: 101
- Watchers: 10
- Forks: 24
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-qa-links - Shock HTTP Mocking Framework
README
# Shock
### Warning: This library is not supported by Just Eat Takeaway anymore and therefore considered deprecated. The repository has been archived.
An HTTP mocking framework written in Swift.
## DemoApp
The DemoApp is a sample app that shows how to use the Shock framework.
- `Test Shock`: will show how to emebed Shock in your app and how to use it to mock API calls.
- `Test ShockRecorder`: will show how to use ShockRecorder to record API calls and how to use the recorded API calls to mock API calls during UI Tests.### Recording API calls with ShockRecorder
To record API calls during the demo app execution, enable the `SAVE_API_RESPONSES_ON_DISK` argument passed on launch in the `DemoApp` scheme.
Once the flag is enabled, the API responses will be saved in the `data_responses` folder, you can find the path in the console logs, e.g.
```
[ShockRecorder] filePath: file:///Users/user/Library/Developer/CoreSimulator/Devices/BE295F5C-5D11-4C70-A74E-52AF3389F0C9/data/Containers/Data/Application/A49E2BCB-1E12-4A34-8DE8-9262742BC564/Documents/data_responses/2023-09-23-16-23-31_001_GET_api_breeds_image_random.json
```To record API calls during the UITests execution:
- Uncomment the line ```app.launchArguments.append("SAVE_API_RESPONSES_ON_DISK")```
- Make sure that UI Test are not executed in parallel.
- Run the UI Tests (They should fail as the API response changes every time)
- Fix the UI Tests with the new API responses, if you want to adapt them the new responses.
- Copy the new API responses from `data_responses/UITests` folder to `Demo/UITests/Resources/RecordedMocks` folder once you want to update the old API responses.