test_utils library
Flutter test utilities for code built on top of armature_flutter.
Usage from a widget test file:
import 'package:armature_flutter/test_utils.dart';
void main() {
testWidgets('renders title from slot', (tester) async {
final container = await startedContainer(features: [root, child]);
initTestRenderer(container);
await pumpFeature(
tester,
container: container,
feature: root,
child: SingleSlotProvider(
slot: titleSlot,
data: null,
builder: (w, _) => w ?? const Text('default'),
),
);
expect(find.text('Hello'), findsOneWidget);
});
}
This sub-library pulls in flutter_test — import it only from test
code. Production code must not reach for these helpers.
Extensions
-
FeatureTestExtensions
on Feature<
TStores, TExports, TPorts> -
Test-scoped extensions on
Feature. Only available whenpackage:armature/test_utils.dartis imported.
Functions
-
collectErrors(
{int? maxResolveConcurrency}) → ErrorCollector - Creates a pre-wired error collector.
-
initTestRenderer(
AppContainer container, {FlutterRendererOptions? options}) → void -
Installs a
FlutterRendereroncontainerso slot widgets can render. The renderer is per-container — call this on each container built by a test that isn't going through ArmatureApp (which sets its own renderer duringinitState). -
noopErrorHandler(
{required String source, required ArmatureError error, required Map< String, String> meta}) → void - Error handler that swallows every error. Use in tests where the recoverable-error path isn't the subject under test.
-
pumpFeature(
WidgetTester tester, {required AppContainer container, required AnyFeature feature, required Widget child, TextDirection textDirection = TextDirection.ltr}) → Future< void> -
Shortcut for
tester.pumpWidget(wrapForTesting(...)). -
silentOptions(
{int? maxResolveConcurrency}) → ContainerOptions -
Convenience builder for
ContainerOptionswith noopErrorHandler and no logger. -
startedContainer(
{required List< AnyFeature> features, ContainerOptions? options, Logger? logger}) → Future<AppContainer> -
Spins up an
AppContainer, registers disposal viaaddTearDown, and awaitsstart(). Returns the ready-to-use container. -
wrapForTesting(
{required AppContainer container, required AnyFeature feature, required Widget child, TextDirection textDirection = TextDirection.ltr}) → Widget -
Wraps
childinDirectionality → ContainerContext → FeatureContext, the minimal ambient tree required by the armature Flutter providers.
Typedefs
-
ErrorCollector
= ({List<
ArmatureError> errors, ContainerOptions options}) -
Paired result from collectErrors: a
ContainerOptionswhoseerrorHandlerappends every error intoerrors.