Skip to main content

avoid-test-in-test-invocation

effort: 4m
pro+

Warns when a test is invoked within another test invocation.

Such invocations will not be properly called by the testing framework and should be moved out.

Example​

❌ Bad:

void main() {
test('some test', () {
// LINT: Avoid declaring tests or test groups inside other tests.
// Try moving this test out.
test('some other test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
});
}

✅ Good:

void main() {
test('some test', () {
...
});

test('some other test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
}