germsvel

germsvel

Test-Driven Development with Phoenix (self-published) (free)

:wave: Hi there,

I’ve been working on a Test-Driven Development with Phoenix book. It teaches TDD and BDD by building a chat app from the outside-in. It’s still a work in progress, but the overall TDD process is clear, and the application that we build throughout the book is fully functional. So, I believe people can already benefit from it.

The book is freely available online at tddphoenix.com.

If you’re interested in the process of writing it, I talked some about it in episode 18 of the Thinking Elixir podcast

I hope some find it helpful.

Most Liked

slouchpie

slouchpie

This is really amazing work! Well done for getting over the “fear” of sharing with the world. Karma+1 for you. :heart:

germsvel

germsvel

Why did we pick Doorman over phx.gen.auth?

That’s an excellent question. I picked Doorman because it was something simple at the time when I started writing the book (a couple of years ago). But changing that chapter to use phx.gen.auth (or something like that) is in my list of to-dos for v1.

If you’re interested in what else is on the roadmap for v1, I wrote a short list in TDD Phoenix Update (Nov 2020)

mstibbard

mstibbard

I ended up switching to Linux just to follow this tutorial as I never figured out how to fix those Windows permissions, and I can confirm it was well worth it. This was exactly what I needed - fantastic work.

I’d advise new Elixir/Phoenix coders follow this book even if they never intend to do TDD… it’s such a great way of learning as it helps you grasp the logic (and in particular what common errors mean) much quicker than just trial and error. Although I have a feeling most people will be keen on TDD by the time they are done :slight_smile:

JoeZMar

JoeZMar

This book is exactly what I have needed. I remember when I started developing in Rails there was a TDD book that really helped me fully understand the development cycle. For the longest time it was what I gave credit to my first dev job.

I moved to Elixir/Phoenix and the one thing my applications felt missing compared to my Rails ones was my test suite. I was confident in most of my Rails tests because I 100% TDD, but the tests I was previously creating for elixir were not near as good. This book definitely gave me the perspective I needed for the current Phoenix project I am working on.

I did have problems running the async tests with Wallaby, so I cheated and just limited to number of async tests I can run to 1 with mix test test/chatter_web/features --max-case=1 to make the tests pass. I was using a Mac with chrome driver.

germsvel

germsvel

Hi @tjdam, thanks for reading the book.

I may be head of myself here, but it seems like the type of workflow you use in the book with Wallaby and all would be the best fit for the type of apps I’m building?

I think I understand your question, but please correct me if I misunderstood it.

When I build APIs, I follow the same outside-in process that I follow in the book. The difference is that the outermost test is usually a controller test (or something equivalent). So you would not need Wallaby.

Wallaby’s purpose is to emulate browser interactions in our tests. Since you’re building APIs, that’s not needed. But the rest of the outside-in process should be the same.

Whatever the application’s domain, I usually try to find the test that best describes a feature for my customers. In APIs that tends to be an endpoint. So that’s where I define the outermost test, and then drive the implementation from there.

Where Next?

Popular in Books Top

PragmaticBookshelf
Kevin Hoffman edited by Kelly Talbot @KellyTalbot Reality is event-sourced; your mind processes sight, sound, taste, smell, and touch to...
New
AstonJ
https://www.packtpub.com/sites/default/files/B04907_MockupCover_Normal.jpg by Kenny Ballou Elixir, based on Erlang’s virtual machine a...
New
PragmaticBookshelf
This project based book gets you up to speed on building and deploying Elixir IoT applications using Nerves, as you develop a real-world ...
New
arpan
:wave: Hey Elixir Enthusiasts! I’ve got something cool for you. It’s a free book on Elixir that dives into the nitty-gritty of concurren...
New
PragmaticBookshelf
Andrea Leopardi @whatyouhide edited by Jacquelyn Carter @jkcarter TCP, UDP, DNS, HTTP, and more: these are the network protocols that ma...
New
AstonJ
By Simon St. Laurent If you’re new to Erlang, its functional style can seem difficult, but with help from this hands-on introduction, y...
New
peerreynders
Don’t forget you can get 35% off the ebook using the code: devtalk.com :023: Note: Check out this thread for help running code in lat...
New
PragmaticBookshelf
Peter Ullrich (@PJUllrich) edited by Michael Swaine @michaelswaine Data is at the core of every business, but it is useless if nobody ca...
New
peerreynders
by Darin Wilson and Eric Meadows-Jönsson Languages may come and go, but the relational database endures. Learn how to use Ecto, the prem...
New
shankardevy
Dear Elixir Alchemists I’m happy to share that I’m working on my 2nd series of books (See my first one here) and this time it’s about As...
New

Other popular topics Top

vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement