I'm using standalone autotest in my projects along with minitest. In one of my projects, I have a single file (validation.rb
) that validates a document to different internal format levels. (A Level 2 document has more features than a Level 1 document.)
Testing the validation for a particular level requires repeatedly loading in a known-valid document, subtly mutating it in broken way, and then ensuring that it is broken. In short:
class TestValidation < MiniTest::Unit::TestCase
def setup
@l1 = Document.load( L1DOC )
end
def test_valid
assert @l1.valid_level_1?
end
def test_unbalanced_data
@l1.instance_eval{ @tracks[0].data.pop }
refute @l1.valid_level_1?, "Validation must ensure that all tracks have the same amount of data"
end
# many more tests for level 1 here
end
The problem is that autotest (as far as I can tell) knows which tests to run based on the name of the test classes. TestValidation
will have its tests automatically run when validation.rb
is changed.
Without autotest, I would have named the above class TestL1Validation
, and created a new class TestL2Validation
that loaded a different document. Doing this breaks autotest, however, unless I break out my validation into l1validation.rb
and l2validation.rb
.
How can I name my files or tests, or set up my tests, so that autotest will run multiple test classes when a single source file changes?