Feature #35030

Allow parallel testing

Added by Go MAEDA 7 months ago. Updated 7 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Rails support
Target version:5.0.0
Resolution:Fixed

Description

Rails 6.0 or later supports parallel testing. Enabling this feature can reduce the time required for testing and improve development efficiency.
https://guides.rubyonrails.org/testing.html#parallel-testing

By applying the following patch and run the test suite with PARALLEL_WORKERS=6 environment variable in my environment, the time required to run the test suite was reduced to about 30%.

diff --git a/test/test_helper.rb b/test/test_helper.rb
index 10f4f6e35..95b877d44 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -53,6 +53,8 @@ class ActionView::TestCase
 end

 class ActiveSupport::TestCase
+  parallelize(workers: 1)
+
   include ActionDispatch::TestProcess

   self.use_transactional_tests = true

The reason why the number of workers is set to 1 is that parallel testing causes some errors in system test.

35030.patch Magnifier (907 Bytes) Go MAEDA, 2021-04-06 02:19

Associated revisions

Revision 20920
Added by Go MAEDA 7 months ago

Allow parallel testing (#35030).

Patch by Go MAEDA.

Revision 20928
Added by Go MAEDA 6 months ago

Update svn:ignore to ignore SQLite3 databases for parallel testing (#35030).

Revision 20929
Added by Go MAEDA 6 months ago

Update .gitignore to ignore SQLite3 databases for parallel testing (#35030).

Revision 20930
Added by Go MAEDA 6 months ago

Update .hgignore to ignore SQLite3 databases for parallel testing (#35030).

History

#1 Updated by Go MAEDA 7 months ago

  • File 35030.patchMagnifier added
  • Subject changed from Enable parallel testing to Allow parallel testing
  • Target version set to 5.0.0

Setting the target version to 5.0.0.

#2 Updated by Go MAEDA 7 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the change.

Now you can run tests in parallel by setting PARALLEL_WORKERS environment variable.

PARALLEL_WORKERS=8 bin/rails test

#3 Updated by Go MAEDA 7 months ago

  • Description updated (diff)

Also available in: Atom PDF