O'Reilly logo

Test-Driven iOS Development with Swift 3 by Dr. Dominik Hauser

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a login request

Let's assume that a colleague is developing a web service, but it is not finished yet. However, we already know what the API will look like. There will be an endpoint for the login. The URL will be https://awesometodos.com/login; it will take two parameters: a username and password, and it will return a token that has to be used with each further call to the API.

We need a test that asserts that the token that is returned from the login call is put into a token struct.

Add a new iOS | Source | Unit Test Case Class, and call it APIClientTests. Import the main module so that it can be tested (@testable import ToDo), and remove the two template tests.

We will split the login feature into several micro features. As mentioned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required