Read more

parallel_tests: Disable parallel run for tagged scenarios

Henning Koch
April 07, 2013Software engineer at makandra GmbH

Note: This technique is confusing and slows down your test suite.


Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Copy the attached code to features/support. This gets you a new Cucumber tag @no_parallel which ensures that the tagged scenario does not run in parallel with other scenarios that are tagged with @no_parallel. Other scenarios not tagged will @no_parallel can still run in parallel with the tagged test. Please read the previous sentence again.

This can help when multiple test processes that access a single resource that is hard to shard per process (e.g. a search engine).

This might also be a last-resort measure to solve Selenium focus issues, but this would require you un-parallelize all @javascript scenarios, leading to decreased performance of your test suite.

To un-parallelize all @javascript scenarios, change the code at the bottom to this:

Around("@no_parallel, @javascript") do |scenario, block|
  NO_PARALLEL_MUTEX.acquire(&block)
end
Posted by Henning Koch to makandra dev (2013-04-07 18:21)