Skip to content

Commit

Permalink
Re-enable parallel testing (in development)
Browse files Browse the repository at this point in the history
This commit re-enables parallel testing. This takes advantage of the
extra cores available on development machines. I've set
`parallelize(workers: 1)` to retain the current behaviour in CI, but
locally a developer can run `PARALLEL_WORKERS=8 bin/rails test` for
example to take advantage of additional cores.

I had to make CreatingAnArtistTest more deterministic - relying on
finding the artist specifically rather than calling `Artist.last` to
make it run alongside other tests in parallel. I also added a text
assertion for good measure to ensure the Artist had been created
before the `artist_path` was visited.
  • Loading branch information
chrislo committed Dec 11, 2024
1 parent a6a0167 commit 3f1063b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/system/creating_an_artist_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class CreatingAnArtistTest < ApplicationSystemTestCase
attach_file 'Profile picture', Rails.root.join('test/fixtures/files/cover.png')

click_on 'Save'
assert_text 'Artist was successfully created'

visit artist_path(Artist.last)
visit artist_path(Artist.find_by(name: 'The Beatles'))

assert_text 'The Beatles'
assert_text 'Liverpool'
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

module ActiveSupport
class TestCase
parallelize(workers: 1)

include FactoryBot::Syntax::Methods

WebMock.disable_net_connect!(allow_localhost: true)
Expand Down

0 comments on commit 3f1063b

Please sign in to comment.