Saltar al contenido principal

missing-test-assertion

added in: 1.6.0 warning

Warns that there is no assertion in the test.

By default the rule checks for expect, expectLater, all expectAsync... variants and fail in test and testWidgets methods.

Config

Set include-assertions (default is none) to include additional assertions.

Set include-methods (default is none) to check additional test methods for missing assertions.

dart_code_linter:
...
rules:
...
- missing-test-assertion:
include-assertions:
- verify
include-methods:
- customTest

Example

Bad:

test('bad unit test', () {
// Given
final a = 1;
final b = 2;

// When
final c = a + 1;
});

Good:

test('good unit test', () {
// Given
final a = 1;
final b = 2;

// When
final c = a + 1;

// Then : actual assertion
expect(b, c);
});