Skip to content

Fake It Til They Make It - Mocking REST APIs for Building & Testing Clients

Photo of Chris Woodard
Hosted By
Chris W.
Fake It Til They Make It - Mocking REST APIs for Building & Testing Clients

Details

When developing and testing a REST client app, it's useful to be able to plug in canned responses. There are already frameworks available that build an in-process HTTP server to vend out test data and they work, but they're one more thing to manage. Also, if you have to run your source code through a vulnerability scanner the presence of a live HTTP server will set of sirens that you'll have to deal with.

There is another way to accomplish the same thing without importing external frameworks, and all it takes is some design thought and knowledge of protocols - dependency injection. In this talk I will develop a REST client in Swift using dependency injection and a mock API back end to get a three-fer: (1) a reliable unit testing substrate for REST client code, (2) a "playable demo" that can be used for UI-level testing of user flows and (3) a way to develop UI and business logic code in advance of an API being available.

Photo of Suncoast iOS group
Suncoast iOS
See more events
ActSoft, Inc.
10006 N Dale Mabry #100 · Tampa, fl