avoid-test-on
Warns when a test invocation has testOn.
Incorrectly configured or left over testOn argument results in the test never being invoked, without any indication from the testing framework.
Instead of adding testOn to individual invocations, consider moving such tests to separate files with a dedicated file name and a top-level @TestOn annotation.
Example
❌ Bad:
void main() {
// LINT: Avoid adding 'testOn' to individual test cases.
// Consider moving this test to a separate file with a top-level @TestOn() annotation.
test('some test', testOn: 'windows', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
}
✅ Good:
void main() {
test('some test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
}