-
Notifications
You must be signed in to change notification settings - Fork 2
Using Fixtures in Minitest
Ngan Pham edited this page Feb 24, 2026
·
1 revision
# test/test_helper.rb
require "fixture_kit/minitest"
class ActiveSupport::TestCase
self.use_transactional_tests = true
endThe Minitest entrypoint sets:
-
fixture_pathdefault totest/fixture_kit - adapter to
FixtureKit::MinitestAdapter
class ProjectTest < ActiveSupport::TestCase
fixture "project_management"
test "loads data" do
assert fixture.project.present?
end
endFor a class that declares fixture:
- Declaration is registered when the class body is evaluated.
-
run_suitegenerates cache once for that class before test methods execute. -
setupmounts cache and assigns repository to@_fixture_kit_repositoryfor each test.
Runner start (FixtureKit.runner.start) is triggered from class-level run_suite before first cache generation and clears cache path unless preserve-cache is enabled.
- Declarations are class-level.
- Subclasses can declare a different fixture and override parent behavior.
If a class doesn’t declare fixture and still calls fixture, FixtureKit raises:
No fixture declared for this test class. Use `fixture "name"` in your test class.