test_reflective_loader
0.6.0, released 7 weeks ago by tools.dart.dev
Runs test suites and methods discovered via reflection.
What it does
Provides functions to define reflective test suites and classes. It automatically discovers test methods, handles setUp/tearDown, and integrates with package:test grouping.
AI-written summary of version 0.6.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to write tests without manually listing each test method
- You need hierarchical test groups generated from class names
- You prefer annotation‑based test discovery in Dart
Skip it when
- You are targeting platforms where reflection is disabled (e.g., Flutter web)
- You need fine‑grained control over test registration beyond class‑based grouping
Strengths
- Reduces boilerplate by auto‑discovering test methods
- Integrates with package:test's group hierarchy for better IDE support
- Supports expected‑fail and skipped tests via annotations
Weaknesses
- Relies on Dart reflection which may not be available in all environments
- Adds an extra dependency on package:test
- Limited to simple naming/annotation conventions
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(MyTestClass);
});
}
@reflectiveTest
class MyTestClass {
void test_example() => expect(true, isTrue);
}Works with
Packages commonly used together with test_reflective_loader: ones it builds on, ones built on it, and its own family.
- testtest_reflective_loader depends on itA full featured library for writing and running Dart tests across platforms.
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- test_descriptorSame familyDeclarative API for creating and verifying file and directory structures in tests.
- test_processSame familyUtility for testing subprocesses with line‑by‑line stdout/stderr streams.