Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write test cases in Phoenix framework equivalent to ROR

How can we pre-load data in test database for integration testing, like in Ruby-on-Rails we have fixtures for that. Is there any good documentation for writing test cases in Phoenix?

like image 679
ayush lodhi Avatar asked Sep 22 '15 12:09

ayush lodhi


1 Answers

For integration tests you may want to take a look at Hound, which is something like Capybara for Elixir. They have some nice examples to get you started.

In Phoenix there is no standard way of loading fixtures like in Rails as far as I know. My personal opinion is that it is better to just have a minimal setup for each test case, instead of complicated global fixtures. It makes it much easier to see what you are actually testing, and which fixtures are really relevant to the current test case. I would say it is better to spend your time creating some helpers that will allow you to easily create records for testing. You might also find the Blacksmith and Faker projects useful for creating test data.

like image 66
Patrick Oscity Avatar answered Nov 06 '22 18:11

Patrick Oscity