I am building a Phoenix application and am putting together a suite of tests. The tests are hitting an actual postgres database using an Ecto sandbox adapter as recommended in the docs.
I would like to ensure that there is some test data available before the tests are run (some test users, some test tenants, etc.)
What’s the recommended strategy for this in Phoenix/Ecto, here’s some ideas I have:
- Write a migration that inserts the test data so I can guarantee it is there. Con: Will mean the data is also in production.
- In the ConCase add a setup that will add the test data. Con: will slow down the tests as this will run before every test.
- Add the data in a setup_all but I can’t figure out how to get this working given the Sandbox.
What do you think re #3 or are there other options?