What is the best way to generate seed data for end-to-end testing

We are going to be building a Phoenix project that will be consumed by a React Native app.

The RN devs want to be able to run end-to-end automated tests to go through certain scenarios in an iOS simulator.

I was thinking that I could provide something like mix test.setup which would clean out and populate the database with all the data required for this type of testing.

Elixir won’t be driving out the tests, so simply running the seed command from inside test_helper.exs isn’t going cut it (as suggested here)

I imagine the final solution will be ran from a CI server and the script will look something like;

set_up_deps
sort_out_database
run_crazy_reactnative_test_runner
clean_database

In your opinion, would it be better to create my own task for this, or should I use Phoenix’s built in seed functionality?

1 Like

Typically I use the built in seeds file to update data that the application is going to depend on and not for fake testing data. I create a separate task for inserting fake data specifically for tests or development and append it to the mix test alias in mix.exs.

I’m sure you’ve thought of this but just watch out for overly coupling yourself to your seed data in your tests. Relying too heavily on seed data is a really fast way to build a brittle test suite. The more data you can build from react native the better.

1 Like

Thanks @keathley, that makes a lot of sense.

Yeah the issue of coupling is something we’ve considered and feel it is worth the risks for what we want to achieve. I imagine this is something we will revisit a good few times whilst we get a good balance of data.

1 Like