Fast Specs with Automated Testing Tools


by Martin Führlinger, Backend Engineer

In the backend team we usually try to automate things. Therefore we have tons of tests to verify correctness of our code in our gems and services. Automated tests are executed much faster and with much higher coverage than any tester can do manually in a similar time. Over the years a lot of functionality has been added, and as a result, a lot of tests have been added. This led to our test suites becoming slower over time. For example, we have a service where around 5000 tests take about 8 minutes. Another service takes about 15 minutes for around 3000 tests. So why is service A so fast and service B so slow? 

In this blog post I will show some bad examples of how to write a test, and how to improve automated testing tools to make tests faster. The Runtastic backend team usually uses `rspec` in combination with `factory_bot` and jruby. 

The Test File Example

The following code shows a small part of a real example of a test file we had in our test suite. It creates some users and tries to find them with the UserSearch use case.

describe  Users::UseCase::UserSearch::ByAnyEmail do
describe “#run!” do
   subject { Users::UseCase::UserSearch::ByAnyEmail.new(search_criteria).run! }
  …

Source link

CHECK OUT THE LATEST: Exercise Bikes On Sale

Leave a Comment