Programming Phoenix - Test times much slower than the book

Working through Programming Phoenix. In Chapter 8 Testing MVC, I’ve added the tests as listed in the book and they pass as expected, but I noticed a HUGE difference in the time it takes.

The output from my tests

Finished in 8.1 seconds (8.1s async, 0.00s sync)
9 tests, 0 failures

The output listed in the book

Finished in 0.2 seconds
9 tests, 0 failures

Anyone else come across the same issue? Any suggestions on how to get my tests running as fast as expected?

I’ve tried running the tests as they are provided in the book’s source code, but since it’s a little bit of a older book, it looks like it’s incompatible with the version of Elixir and/or Erlang on my machine.

1 Like

Are the slow tests by any chance related to the user password hashing?
I dont remember exactly if the book uses bcrypt but if thats the case do you have the correct setup on your test config?

config :bcrypt_elixir, log_rounds: 4
1 Like

@cpgo Thanks, I think that’s it.

The book uses pbkdf2_elixir, but I added this to config/test.exs:

config :pbkdf2_elixir, :rounds, 1

And looks like I’m good to go, the whole suite is now running in about 1 second.

1 Like

If I remember correctly, the book first lets you experience that tests are getting slower, then it explains how to fix it with the config approach you mentioned.

@sabiwara You are correct.

1 Like