Testing JSON-Based APIs

We’re going to start by looking at testing a JSON-based API. This is a very common use case for Phoenix and it’s the least complex of the interfaces we’ll test. This will allow us to focus on some concepts that will apply across all of the interface types we’ll cover, without getting too lost in the specifics of the interface itself.

What Controller Tests Need to Cover

We strive to keep our controllers as small as possible, with as little branching logic as possible. This accomplishes two goals: it keeps our business logic out of the web part of our application, and it keeps the number of test cases needed to a minimum. Controller tests are some of our most expensive (in terms of running time) since they often require ...

Get Testing Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.