I am trying to run my Rspec tests in Parallel but doing so causes data conflicts i.e I have a delete_all method to give me a clean slate every tests run which causes tests running in parallel to lose the data they have created. What would be the ideal way to resolve this?
1 Answer
Separate Databases.
Not sure how you are running your tests in parallel. Parallel tests should each have their own databases, otherwise, yes, you'll get massive data conflicts.
If your parallel test runners are sharing the same database and you call delete_all on one of your runners, it will cause the other runners to fail because their test databases (which are all the same) will now be empty.
Gems like parallel_tests use separate databases for each test runner by suffixing the test database name with the runner number, e.g. test_database1, test_database2, etc.
So, you should use one of these pre-built libraries that helps take care of this but if you're rolling your own, then make sure you run each runner in a separate database to avoid database conflicts.
page.findif I haven't deleted the element from the previous test run, it will result in ambiguous result. @TarynEast