Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

fix: add fail assertion as a valid method to missing_test_assertion rule #1069

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class _MethodAssertionVisitor extends RecursiveAstVisitor<void> {
'expectAsyncUntil5',
'expectAsyncUntil6',
'expectLater',
'fail',
};

_MethodAssertionVisitor(Iterable<String> includeAssertions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@ void main() {
expectAsyncUntil6((p0, p1, p2, p3, p4, p5) {}, () => true);
});

test('with fail', () {
fail('some failure reason');
});

test(null, () => expect(1, 1));
}
2 changes: 1 addition & 1 deletion website/docs/rules/common/missing-test-assertion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import RuleDetails from '@site/src/components/RuleDetails';
Warns that there is no assertion in the test.

Use `include-assertions` configuration, if you want to include specific assertions.
Defaults to Dart default assertions including expect, expectLater and all expectAsync variants.
Defaults to Dart default assertions including expect, expectLater, all expectAsync variants and fail.

Use `include-methods` configuration, if you want the linter to check particular test methods for missing assertions.
Defaults to `test` and `testWidgets` methods.
Expand Down