After an upgrade, I'm finding the same several test methods failing, so I'd like to automate testing just those instead of all methods in all classes. I want to list each class-method pair (e.g. TestBlogPosts.test_publish
, TestUsers.test_signup
) and have them run together as a test suite. Either in a file or on the command-line, I don't really care.
I'm aware of these techniques to run several entire classes, but I'm looking for finer granularity here. (Similar to what -n /pattern/ does on the command-line - to run a subset of test methods - but across multiple classes.)
You could renounce
minitest/autorun
and callMinitest.run
with your self defined test selection.An example:
The result:
When you call the following test:
then you get
The
Minitest.run
takes the same parameters you use from the command line. So you can use the-n
option with your selection, e.g./MyTest1.test_subtract|MyTest2.test_add/
.You could define different tasks or methods with different
Minitest.run
-definition to define your test suites.Attention: No test file you load may contain a
require 'minitest/autorun'
.