This skill defines how to write effective, meaningful Flutter and Dart tests.
Before writing or accepting a test, ask:
"Can this test actually fail if the real code is broken?"
Always use group() in test files — even when there is only one test. Name the group after the class under test:
group('Counter', () {
test('value should start at 0', () {
final counter = Counter();
expect(counter.value, 0);
});
});
Name test cases using "should" to clearly describe the expected behavior:
test('should emit updated list when item is added', () { ... });
test('should throw ArgumentError when input is negative', () { ... });