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

collegeimprovements
https://imagery.pragprog.com/products/579/lmelixir.jpg?1591050736 by @whatyouhide and @idlehands Elixir offers new paradigms, and chal...
New
AstonJ
Don’t forget you can get 35% off the ebook using the code ‘devtalk.com’ :023:
New
CinderellaMan
Hands-on Elixir & OTP: Cryptocurrency Trading Bot by Kamil Skowron Want to learn Elixir & OTP by creating a real-world project...
New
PragmaticBookshelf
This hands-on book will quickly get you building, querying, and comparing graph data models using a robust, concurrent programming langua...
New
AstonJ
By Simon St. Laurent, J. David Eisenberg Elixir is an excellent language if you want to learn about functional programming, and with thi...
New
AstonJ
by Wolfgang Loder Learn and understand Erlang and Elixir and develop a working knowledge of the concepts of functional programming that...
New
AstonJ
By Francesco Cesarini, Simon Thompson This book is an in-depth introduction to Erlang, a programming language ideal for any situation wh...
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
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
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

We're in Beta

About us Mission Statement