Introducing how to create HTTP stubs for your application and/or unit or UI tests. We're using the Mockingjay library in Swift to create these mocks.
- Level: beginner
- Workshop at FrenchKit 2017 conference.
- Your Mac
- Xcode 8 or 9
- A bit of Swift…
- Paw (get the 30 days trial)
- Intro & Presentation
- A simple XKCD client app with Alamofire
- Build mocks with Mockingjay
- A simple Instagram client app
- Create unit + UI tests with mocks
- Build a client app for the XKCD website (using their API)
- Mock the API to make the tests pass independently from the API
- Introducing the Instagram API
- Import the Instagram API in Paw File > Import > Find API Template
- Download ready-to-go Paw file
- Generate Alamofire code snippets with Paw
- Build & run
- Create a new Instagram client app – load your own Instagram feed
Use the Instagram app for that, set up tests for each feature, and people can implement the stubs.
- Build a unit test case for
Instagram.loadImages(tag:, count:)
- Use Paw to generate mocks from an existing response. Install Mockingjay Code Generator
- Write mocks to test the API
- Example of what JSON Schema is and used for
- Add validation to your app to assert the server results