Unable to run single test with Rails/Minitest

3 weeks ago 24
ARTICLE AD BOX

We have two almost identically set up Rails (v8.1.1) applications, both with Minitest (v5.27.0) as the testing framework. But in Application A we can run single tests from a file, but not in Application B. I've tried to compare the setup of both, but can't see a noticeable difference that would cause this.

Example test:

require 'application_system_test_case' class DeviceTest < ApplicationSystemTestCase def setup @device = device(:foo) end test '404' do visit '/device/0' assert_title "The page you were looking for doesn't exist (404)" end test '/device/1' do visit "/device/1" assert_selector 'h1', text: @device.name end end

If I run the above test with rails test test/system/device_test.rb:8 with App A, only the 404 test is run (which starts on line 8). But If I do this in App B, all tests from that file are run (so both the test on line 8 and line 13).

What can cause this, and how can I fix this?

(Because it's rather annoying to run either all tests from a file, or comment out the tests I don't need)

Read Entire Article