Phoenix - Seeding Your Tests
If you need to seed your test database when running
Phoenix tests, you can require the seed
file in test/test_helper.exs
:
ExUnit.start
Mix.Task.run "ecto.create", ["--quiet"]
Mix.Task.run "ecto.migrate", ["--quiet"]
# Add this line:
Code.require_file("priv/repo/seeds.exs")
Ecto.Adapters.SQL.begin_test_transaction(Expensive.Repo)
You can, of course, require a different file instead.