Last time we have learned about general testing concepts and have talked about unit testing in Elixir.
Now let’s go further and learn how to add tests to Phoenix project.
We will learn how to write tests for Models and Controllers.
Testing is an important part of software development.
One might argue that projects can survive with manual testing only and many of them do.
But that raises a couple of questions:
- How hard is it to refactor some parts in those projects?
- Ain’t one have a fear to refactor the code which uncovered by tests?
- How much time does it take to check the changes one just did?
- Didn’t those changes break some other part of the project?
- How to prove that the code is working as it supposed to work?
Yes, it requires the time to write tests. But does it take less time to test the stuff manually over and over again?
Some time ago we have already mentioned Ecto while we were describing Ecto models.
Ecto quite a big topic, which we cannot cover in a single post.
Today I would like to talk again about Ecto and describe Ecto Queries.
In the previous article we have implemented chat functionality.
Our users can join a room and start sending messages to a room.
By implementing that we have covered very basic functionality of Phoenix channels.
Today I would like to go deeper and take a look at Presence feature, which ships with Phoenix since version 1.2.
In this article, we will use Presence functionality to implement a list of online users and render the typing indicator next to a username.