fluent_assertions
1.0.0, released 8 weeks ago by klisiewicz.dev
Extension‑based fluent assertions for Dart unit tests, wrapping package:test matchers.
What it does
Provides a rich set of extension methods to write readable, chainable assertions in Dart and Flutter tests. It covers equality, nullability, collections, strings, numbers, maps, and exception handling, all mapping to the standard test matcher API.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want more expressive, readable test assertions without writing matcher code
- You need a comprehensive assertion library covering many data types
- You prefer chaining style assertions in unit or widget tests
Skip it when
- You have strict constraints on package size or want zero dependencies beyond test
- You need custom matcher logic not covered by the provided extensions
Strengths
- Wide coverage of assertion types
- Chains naturally for readable test code
- Zero runtime overhead, just extensions
Weaknesses
- Adds a dev_dependency layer, may duplicate functionality of existing test matchers
- Limited to test environment, not for production code
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:fluent_assertions/fluent_assertions.dart';
import 'package:test/test.dart';
void main() {
test('string length', () {
'hello'.shouldHaveLength(5);
});
test('list contains', () {
[1, 2, 3].shouldContain(2);
});
}
Alternatives
Packages that do the same job and could replace fluent_assertions.
- bdd_widget_test
Generate Flutter widget tests from Gherkin feature files
88Compare - very_good_test_runner
A Dart/Flutter test runner that streams TestEvent objects from dart test or flutter test.
88Compare - total_lints
A very strict set of lints for Dart and Flutter apps.
66Compare - fake_cloud_firestore
Fake implementation of Cloud Firestore for unit testing.
87Compare
Works with
Packages commonly used together with fluent_assertions: ones it builds on, ones built on it, and its own family.