Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 2.04 KB

README.md

File metadata and controls

52 lines (35 loc) · 2.04 KB

From API Description to Tests & Mocks

Download Slides

Introduction

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.

Prerequisites

  • Your Mac
  • Xcode 8 or 9
  • A bit of Swift…
  • Paw (get the 30 days trial)

Today’s Agenda

A – XKCD client app

  1. Build a client app for the XKCD website (using their API)
  2. Mock the API to make the tests pass independently from the API

B – Instagram API with the help of Paw

  1. Introducing the Instagram API
  2. Import the Instagram API in Paw File > Import > Find API Template
  3. Download ready-to-go Paw file
  4. Generate Alamofire code snippets with Paw
  5. Build & run
  6. Create a new Instagram client app – load your own Instagram feed

C – Integrate with Tests

Use the Instagram app for that, set up tests for each feature, and people can implement the stubs.

  1. Build a unit test case for Instagram.loadImages(tag:, count:)
  2. Use Paw to generate mocks from an existing response. Install Mockingjay Code Generator
  3. Write mocks to test the API

D – JSON Schema Validation

  1. Example of what JSON Schema is and used for
  2. Add validation to your app to assert the server results