Reputation: 1
I am debugging a test in minitest (a system test if it matters) and I am encountering some weird behavior. Running the test (below) locally passes fine. However when running in a CI environment I get unexpected behavior.
Here are the versions of things I am using: Ruby v2.7.7 Rails v7.0.4.3 Factory_bot_rails v6.2.0 minitest v5.18.0
class SessionSystemTest < ApplicationSystemTestCase
setup do
@admin = FactoryBot.create :admin
puts "setup admin: #{@admin.inspect}"
@theID = @admin.id
puts "the id: #{@theID}"
end
test "see admin" do
puts "test admin: #{@admin.inspect}"
puts "the id: #{@theID}"
assert_equal @admin.id, @theID
end
end
When running locally everything passes fine and the puts statements tell me that the @admin objects are identical in the setup and in the test.
However when running in the CI env (github actions) The @admin objects are different. The @admin.id looks like it has been incremented. However the @theID variable stays the same.
I'm not sure what to even try to solve this issue. I'm assuming that the setup block is supposed to setup variables for use in the tests, not just define them and have the test re-instantiated them. I initially tried not using instance variables, but that doesn't work due to how minitest is supposed to work. I can lookup the proper entry if I save the id in the setup. But that seems like a bit of a hacky solution.
Upvotes: -1
Views: 96
Reputation: 1
It turns out the issue was that I had two tests in different folders with the same filename/classname. By renaming one of these files/classes it resolved the issue completely.
Upvotes: 0