I spent a bit of time comparing the two based on mid-sized code that uses ActiveRecord tools extensively. When I switched it to using DatabaseCleaner instead of use_transactional_fixtures , the model specifications began to take about twice as much time.
After you did the same comparison, I realized that there are two things that use_transactional_fixtures :
- Regardless of whether each specification is enclosed in a transaction
- In this process, instrument data is loaded using ActiveRecord.
- When
use_transactional_fixtures true, device data is downloaded once, before the first test - When it is false, binding data is loaded before each specification
DatabaseCleaner transaction strategy can replace (1). But the disadvantage is that your package will reload the same device data.
So, if you do not use AR devices (or use only a couple), the transaction strategies use_transactional_fixtures and DatabaseCleaner will have similar performance. But if you use a large number of AR fittings, then disabling use_transactional_fixtures will have a big impact on performance.
Rhett sutphin
source share