prefer-test-body-last
Suggests having the body of a test invocation or test group as its last argument.
Example
❌ Bad:
void main() {
// LINT: The body of a test or group should go after the other arguments.
// Try moving the body argument below other arguments.
test('some test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
}, skip: '');
// LINT: The body of a test or group should go after the other arguments.
// Try moving the body argument below other arguments.
group('some group', () {
test('some test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
}, skip: true);
}
✅ Good:
void main() {
test('some test', skip: '', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
group('some group', skip: true, () {
test('some test', () {
final array = [1, 2, 3];
expect(array, hasLength(1));
});
});
}