Have you ever felt like running more than one kind of test at the same time, because your tests take so long or just to earn some extra free time? I looked for a solution to this problem, and I actually found a good one. The gem is called
parallel_test, and, it give us the functionality and the possibility to run in parallel:
- Unit tests
- Spec tests
- Feature tests
You could run the multiple combinations of these as well at the same time and sharing the same test database.
The speed applied to these tests is relative to the hardware in your device, so if you have the latest generation of microprocessors, you should feel a huge difference on performance while running your tests.
Setup for Rails
# add to Gemfile gem "parallel_tests", :group => :development
1.- Add to your
test: database: your_project_test<%= ENV['TEST_ENV_NUMBER']%>
2.- Create additional database(s)
3.- Copy the development schema (repeat after migrations)
rake parallel:test # Test::Unit rake parallel:spec # RSpec rake parallel:features # Cucumber
rake parallel:test # force 1 CPU --> 86 seconds rake parallel:test # got 2 CPUs? --> 47 seconds rake parallel:test # got 4 CPUs? --> 26 seconds ...
There's a lot more custom options to this gem, you can read all about it here: https://github.com/grosser/parallel_tests