I have a rails 3.0 application with complicated logic and was finding
changes to fix a bug would introduce another bug elsewhere. I needed an
automatic regression test tool so I could quickly know if this happened.
am using cucumber for this. I know that I am not doing BDD or TDD, but
that is beside the point.
My initial set of scenarios was developed using capybara and seeding the
database with test fixtures. Although it mostly worked, there were
switched to selenium. Now none of my scenarios worked. sqlite3 was
complaining about the database being locked because it can only handle
request at a time. I tried switching to a mysql test database, but then
the scenarios did not see the changes the application made to database.
After much googling, I found that both of these problems were because
selenium runs in a separate thread while capybara does not. The
solution for this was to change the database cleaner strategy from
transaction to truncate. After this change, most of the scenarios ran,
for those using the scenario outline, only the first case would pass.
following cases all found an empty database. Truncate was deleting all
database records after the first case and not restoring it. After more
googling I found I could set the database cleaner strategy to nil. Now
of my scenarios pass, but I have to be careful that no two scenarios use
the same database records because database changes are not cleared
scenarios. I also have been able to go back to using sqlite3.
Is there a better alternative?