-
Notifications
You must be signed in to change notification settings - Fork 14
Test filters
Test filters are pretty self-explanatory: they filter the tests of the analysis. There are currently 7 types of test filters:
- MTCompositeTestFilter
- MTFreeTestFilter
- MTBlockTestFilter
- MTPragmaSelectionTestFilter
- MTPragmaRejectionTestFilter
- MTRedTestFilter
- MTTimeTestFilter
This is the default test filter used by the analysis, used with a red test filter and a time test filter.
This test filter works as a combination of multiple test filters. It has a collection of test filters as an attribute, and the test collection passes through each filter. A test is blocked by the composite if any of its filters blocks the test, and it passes through the composite if it passes through all its filters.
To use the composite with, for example, a red test filter and a 2 seconds time test filter:
analysis testFilter: (MTCompositeTestFilter for: { MTRedTestFilter . (MTTimeTestFilter for: 2 seconds) })
This filter doesn't block anything.
analysis testFilter: MTFreeTestFilter new.
This filter uses a block as its condition. Every test that respects the block condition passes through the filter, and every test that doesn't is blocked by the filter. This is the most generic filter, as you can give it any condition you want.
For example if you want to use only the tests whose names end with "filter":
analysis testFilter: (MTBlockTestFilter for: [ :testCase | testCase selector endsWith: 'filter' ]).
This filter lets pass the tests that contain a given pragma and block all other tests.
To let the tests with pass:
analysis testFilter: (MTPragmaSelectionTestFilter for: #testPragma)
On the contrary this filter lets only the tests that don't contain the given pragma pass, and blocks those with this pragma.
To block the tests with :
analysis testFilter: (MTPragmaRejectionTestFilter for: #testPragma)
This filter rejects the tests that are initially red. That is to say, during the initial test run, if there are tests that fail even without any mutation installed, the filter will remove them.
To apply this filter:
analysis testFilter: MTRedTestFilter new
This filter selects the tests that take less than the given duration to run. During the initial test run the time taken by each test is saved, so the filter uses those times to select which one it keeps or removes.
To keep the tests that only take less than 2 seconds to run:
analysis testFilter: (MTTimeTestFilter for: 2 seconds)