Back

System tests

For a long time most Rails developers have been using the Database Cleaner gem to manually truncate their databases during test runs. This was mostly required because we couldn't switch on transactional fixtures when doing Javascript automated testing. The external JS driver in feature specs prevented transactional fixtures being able to be used (as it was in a seperate thread to Rails), which often resutled in a messy test database and tons of Flaky errors.

Rails 5.1 introduces System tests to replace Feature tests which brings the test suite into a single process, therefore eliminating the need for Database Cleaner and switching off transactional fixtures. This is a pretty big advantage over javascript feature specs, as these needed to database truncation after each test which is incredibly slow.

When I implemented it I needed to dump my test database as it had records that were not cleaned up from the last test run (on account of removing DB Cleaner)

This is a pretty great article about system tests