Chapter 13
Testing Channels and OTP

The last few chapters were packed with new features. We’ve spent quite a bit of time and effort establishing new features that are interactive, compelling, and fast. Our information system uses an external API with flexible backends. Our channels-based API offers real-time web support for a rich user interface, one extremely sensitive to good server performance. Our channels allow peer-to-peer messaging. We’re missing only one thing. Tests.

In this chapter, you’ll see how to test OTP processes in isolation. You’ll learn to use the Phoenix helpers to simplify channels testing. Before we dive in, let’s briefly talk about what you can expect.

Recall that in Part I, the test cases for our controllers used Phoenix test helpers in ConnCase. We tested our HTTP-backed features, the router, controller, and views. Our integrated tests also hit the database. We used helpers such as html_response to remove some of the boilerplate from our typical tests.

In Part II, our code stack is fundamentally different. The MVC code gave way to channels and OTP. Still, the basic approach will be the same. We’ll build tests that hit a single channel call, one that integrates everything down to the database.

We’ll draw the line at the external requests. Since we want to run our integration tests within our sphere of control, we’ll want our usual test stack to focus on everything we’ve built except our external HTTP request to WolframAlpha. We’ll want to isolate our tests from that piece of code.

Let’s start our testing process with our information system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.75.221