testing library

Test support for package:better_effect_flutter.

This entrypoint re-exports core testing helpers and adds deterministic Command-state, listener-delivery, policy-decision, and widget-boundary utilities.

Classes

AutoInjectorBackend
The default ResolverBackend, powered by package:auto_injector.
BetterEffectBootstrap
Declaratively starts an application-owned Runtime inside Flutter.
BetterEffectFeatureScope
Owns one child Runtime for a Flutter feature subtree.
BetterEffectLifecyclePolicy
Controls when and how an owned Runtime shuts down.
BetterEffectProvider
Places an existing Runtime in the Flutter tree with explicit ownership.
BetterEffectScope
Exposes a long-lived better_effect Runtime and its EffectCommands to a Flutter subtree.
BetterEffectTestApp
Minimal widget-test boundary for an externally owned Runtime.
Binding
A declarative service registration used inside a Module.
CancellationSignal
A cooperative cancellation signal exposed to an active Effect.
CleanupFailureDiagnostic
Describes a cleanup failure reported after an Effect outcome was known.
CleanupFailureEvent
Runtime-observer projection of an existing cleanup diagnostic.
CommandPolicy
Immutable execution and timing policy for an Effect Command.
Effect<A extends Object, E extends Object>
A lazy computation that can succeed with A or fail with E.
EffectClock
A replaceable source of wall-clock time and cooperative delays.
EffectCommand<I, A extends Object, E extends Object>
An Effect command with one typed input.
EffectCommand0<A extends Object, E extends Object>
An Effect command without input parameters.
EffectCommandBase<A extends Object, E extends Object>
A Flutter-facing command that executes typed Effect values through a long-lived Runtime.
EffectCommandBuilder<A extends Object, E extends Object>
A typed Command-state builder with optional transition filtering.
EffectCommandConsumer<A extends Object, E extends Object>
Combines one-shot command side effects with state-driven UI rendering.
EffectCommandDefect<A extends Object, E extends Object>
The Effect terminated because of an unexpected defect.
EffectCommandDisposable
The minimal lifecycle contract shared by all Effect command variants.
EffectCommandFailure<A extends Object, E extends Object>
The Effect completed with an expected, typed failure.
EffectCommandIdle<A extends Object, E extends Object>
The command has not started, or has been reset.
EffectCommandInterrupted<A extends Object, E extends Object>
The command stopped owning an active execution result.
EffectCommandListener<A extends Object, E extends Object>
Delivers command transitions as one-shot Flutter presentation effects.
EffectCommandListenerProbe<A extends Object, E extends Object>
Records states delivered by EffectCommandListener.onChanged.
EffectCommandPolicyEvent
Immutable diagnostic event for Command policy decisions.
EffectCommandPolicyProbe
Records EffectCommandPolicyEvent values in delivery order.
EffectCommandProbe<A extends Object, E extends Object>
Records visible EffectCommandState revisions without owning the Command.
EffectCommandRunning<A extends Object, E extends Object>
The command is executing an Effect.
EffectCommands
Creates EffectCommand0 and EffectCommand instances bound to one long-lived Runtime.
EffectCommandSelector<A extends Object, E extends Object, S>
Rebuilds only when a selected Command value changes.
EffectCommandSnapshot<A extends Object, E extends Object>
Read-only state and coordination metadata for one Command.
EffectCommandState<A extends Object, E extends Object>
The observable UI state of an EffectCommandBase.
EffectCommandSuccess<A extends Object, E extends Object>
The Effect completed successfully.
EffectCommandTransition
One state transition produced by an Effect command.
EffectContext<E extends Object>
The capabilities available inside Effect.result.
EffectExecution<A extends Object, E extends Object>
A managed handle for one Effect execution.
EffectLocal<T extends Object>
A runtime-local value inherited by nested Effects.
EffectLocalBinding
A heterogeneous, type-safe local binding.
EffectRandom
A replaceable source of uniform random values for Effect policies.
EffectViewModel
Optional MVVM base class with concise, automatically disposed command creation.
EffectViewModelBuilder<T extends ChangeNotifier>
Creates, observes, and disposes a ViewModel at a Flutter composition boundary without imposing Provider, Riverpod, BLoC, or another state package.
ExecutionEndEvent
Emitted synchronously after physical work and Scope cleanup finish.
ExecutionStartEvent
Emitted synchronously immediately before an Effect runner starts.
Exit<A extends Object, E extends Object>
The complete outcome of running an Effect.
ExitDefect<A extends Object, E extends Object>
An Effect terminated because of an unexpected defect.
ExitFailure<A extends Object, E extends Object>
An Effect completed with an expected, typed failure.
ExitInterrupted<A extends Object, E extends Object>
Execution or runtime ownership ended without a success or typed failure.
ExitSuccess<A extends Object, E extends Object>
An Effect completed successfully.
Failure<S extends Object, F extends Object>
Error Result.
InterruptionEvent
Emitted once when a managed execution first receives cancellation.
ManualEffectClock
Deterministic EffectClock controlled by the test.
Module
A composable collection of service bindings.
RecordingRuntimeObserver
Records Runtime events in callback order for assertions and diagnostics.
ResolverBackend
Backend contract used by Runtime to register and resolve services.
ResolverBackendContractReport
Complete compatibility report for one backend implementation.
ResolverBackendContractResult
Result of one backend compatibility scenario.
ResolverBackendDisposalProbe
Optional fixture used to prove that backend-owned instantiated services are disposed when the backend closes.
ResolverBackendOverlayFactory
Optional backend capability used by execution-scoped Modules and child Runtime environments.
ResourceReleaseEvent
Describes release of one Module or Effect resource.
ResultDart<S extends Object, F extends Object>
Base Result class
RetryContext<E extends Object>
Information available when a typed failure asks a RetryPolicy whether another attempt should run.
RetryEvent
Immutable projection of one retry decision.
RetryPolicy<E extends Object>
Decides the delay before another execution of an Effect.
Runtime
Executes Effects against the environment built from a Module.
RuntimeEventContext
Immutable execution and metadata projection shared by Runtime events.
RuntimeObserver
SDK-neutral, synchronous Runtime instrumentation.
RuntimeObserverError
A callback failure that was isolated from execution semantics.
Scope
Owns finalizers, resources, and child Scopes.
SeededEffectRandom
Reproducible pseudo-random source for tests and deterministic simulations.
ServiceAcquireEvent
Describes acquisition of one Module or Effect resource.
ServiceKey<T extends Object>
A typed name for distinguishing multiple implementations of the same type.
ServiceResolveEvent
Describes one service-resolution attempt.
Services
A read-only, callable view of the services available in a Runtime.
Success<S extends Object, F extends Object>
Success Result.
SystemEffectClock
Host-backed EffectClock using DateTime.now and Future.delayed.
SystemEffectRandom
Host-backed pseudo-random source.
TestEventRecorder<T extends Object>
Records an ordered sequence such as resource acquisition and cleanup events.
TestGate<T extends Object>
A deterministic one-value gate for coordinating asynchronous tests.
TestRuntime
A test-owned Runtime with event recording and deterministic cleanup.
TestSignal
A deterministic signal for tests that only need to release a wait point.
TriggerPolicy
Immutable timing policy for typed-input Commands.
Unit
Used instead of void as a return statement for a function when no value is to be returned.

Enums

BetterEffectRuntimeOwnership
Declares who owns a Runtime placed in the Flutter tree.
CommandPolicyDecision
A policy decision that does not need a new Command state or domain failure.
CommandPolicyKind
Execution coordination used by a CommandPolicy.
CommandPolicyReason
Machine-readable reason attached to EffectCommandPolicyEvent.
EffectCommandConcurrency
Compatibility shorthand for the three original Command coordination modes.
InterruptionSource
Which owner requested cooperative interruption.
Lifetime
Controls how a constructor-backed service is instantiated.
QueueOverflow
Behavior when a bounded Command queue has no remaining capacity.
ResolverBackendContractCase
Behavioral scenarios shared by ResolverBackend implementations.
ResourceAcquisitionSource
Which API acquired a scoped resource.
RetryDecision
Why a retry loop continued or stopped after one attempt.
RuntimeObserverCallback
Identifies the observer callback that raised an instrumentation error.
RuntimeState
Lifecycle state of a Runtime.
ServiceResolutionSource
How a service request was satisfied.
TriggerPolicyKind
Timing stage applied before execution coordination.

Mixins

EffectCommandOwner
Disposes every Effect command owned by a ChangeNotifier.

Extensions

AsyncResultDartEffectInterop on AsyncResultDart<A, E>
Convert an asynchronous Result into an Effect.
AsyncResultDartExtension on AsyncResultDart<S, F>
AsyncResultDart<S, E> represents an asynchronous computation.
BetterEffectBuildContext on BuildContext
Flutter accessors for the nearest BetterEffectScope.
EffectCommandConcurrencyPolicy on EffectCommandConcurrency
Translate the compatibility enum into its exact immutable policy.
EffectRetryOps on Effect<A, E>
Typed-failure retry for every Effect.
EffectTransformOps on Effect<A, E>
Transformations available on every Effect.
FlattenAsyncResultExtension on AsyncResultDart<ResultDart<S, F>, F>
Extension to flatten a nested AsyncResultDart into a single AsyncResultDart.
FlattenResultExtension on ResultDart<ResultDart<S, F>, F>
Extension to flatten a nested ResultDart into a single ResultDart.
FutureResultExtension on Future<S>
Extension on Future<S> to convert it into an AsyncResultDart<S, Exception>.
FutureResultExtensionVoid on Future<void>
Extension on Future<void> to convert it into an AsyncResultDart<Unit, Exception>.
ResultDartEffectInterop on ResultDart<A, E>
Convert a synchronous Result into a lazy Effect value.
ResultObjectExtension on W
Adds methods for converting any object into a Result type (Success or Failure).
RuntimeChildOps on Runtime
Child Runtime operations for feature-length environments.
RuntimeExecutionModuleOps on Runtime
Execution-scoped Module operations for a long-lived Runtime.

Constants

unit → const Unit
Used instead of void as a return statement for a function when no value is to be returned.

Functions

expectCommandDefect<A extends Object, E extends Object>(EffectCommandState<A, E> state) → ({Object defect, StackTrace stackTrace})
Return a Command defect and stack trace or throw a test exception.
expectCommandFailure<A extends Object, E extends Object>(EffectCommandState<A, E> state) → E
Return a typed Command failure or throw a descriptive test exception.
expectCommandIdle<A extends Object, E extends Object>(EffectCommandState<A, E> state) EffectCommandIdle<A, E>
expectCommandInterrupted<A extends Object, E extends Object>(EffectCommandState<A, E> state) EffectCommandInterrupted<A, E>
expectCommandRunning<A extends Object, E extends Object>(EffectCommandState<A, E> state) EffectCommandRunning<A, E>
expectCommandSuccess<A extends Object, E extends Object>(EffectCommandState<A, E> state) → A
Return a successful Command value or throw a descriptive test exception.
expectExitDefect<A extends Object, E extends Object>(Exit<A, E> exit) → ({Object defect, StackTrace stackTrace})
Extract a defect and stack trace or throw an assertion-oriented exception.
expectExitFailure<A extends Object, E extends Object>(Exit<A, E> exit) → E
Extract a typed failure or throw an assertion-oriented exception.
expectExitInterrupted<A extends Object, E extends Object>(Exit<A, E> exit) → void
Assert an interrupted outcome without depending on a test framework.
expectExitSuccess<A extends Object, E extends Object>(Exit<A, E> exit) → A
Extract a successful value or throw an assertion-oriented exception.
inspectResolverBackendContract({required ResolverBackendTestFactory createBackend, ResolverBackendDisposalProbeFactory? createDisposalProbe}) Future<ResolverBackendContractReport>
Run every ResolverBackend scenario and return a detailed report.
isExitDefect<A extends Object, E extends Object>([Object? defect = _unspecified]) → Matcher
Match an ExitDefect with optional defect matching.
isExitFailure<A extends Object, E extends Object>([Object? error = _unspecified]) → Matcher
Match an ExitFailure with optional typed-error matching.
isExitInterrupted<A extends Object, E extends Object>() → Matcher
Match an ExitInterrupted.
isExitSuccess<A extends Object, E extends Object>([Object? value = _unspecified]) → Matcher
Match an ExitSuccess with optional value matching.
runBetterEffectApp({required Module module, required Widget app, ResolverBackend? backend, EffectCommandObserver? observer, EffectCommandPolicyObserver? policyObserver, BetterEffectLifecyclePolicy lifecyclePolicy = const BetterEffectLifecyclePolicy.application(), bool? closeRuntimeOnDetach, BetterEffectStartupErrorBuilder? startupErrorBuilder, void onRuntimeCloseError(Object error, StackTrace stackTrace)?}) Future<void>
Starts an application-owned better_effect Runtime and mounts Flutter.
runResolverBackendContractTests({required ResolverBackendTestFactory createBackend, ResolverBackendDisposalProbeFactory? createDisposalProbe}) Future<void>
Acceptance-test-style alias intended for one ordinary package:test test.
verifyResolverBackendContract({required ResolverBackendTestFactory createBackend, ResolverBackendDisposalProbeFactory? createDisposalProbe}) Future<void>
Verify a backend contract and throw ResolverBackendContractException when any required scenario fails.

Typedefs

AsyncResult<S extends Object> = AsyncResultDart<S, Exception>
A typedef for an asynchronous Result, simplifying the usage of AsyncResultDart with Exception as the default failure type.
AsyncResultDart<S extends Object, F extends Object> = Future<ResultDart<S, F>>
AsyncResultDart<S, E> represents an asynchronous computation.
BetterEffectBackendFactory = ResolverBackend Function()
Creates a fresh resolver backend whenever BetterEffectBootstrap starts or retries.
BetterEffectBootstrapBuilder = Widget Function(BuildContext context)
Builds the application subtree after the Runtime starts.
BetterEffectBootstrapErrorBuilder = Widget Function(BuildContext context, Object error, StackTrace stackTrace, VoidCallback retry)
Builds a startup error UI. Calling retry starts a fresh Runtime.
BetterEffectFeatureBuilder = Widget Function(BuildContext context)
Builds a feature subtree after its child Runtime has started.
BetterEffectFeatureErrorBuilder = Widget Function(BuildContext context, Object error, StackTrace stackTrace, VoidCallback retry)
Builds the startup-error state for a feature child Runtime.
BetterEffectStartupErrorBuilder = Widget Function(Object error, StackTrace stackTrace)
Builds a fallback root when the application Runtime cannot start.
CleanupFailureObserver = FutureOr<void> Function(CleanupFailureDiagnostic diagnostic)
Receives cleanup failures without changing the main Effect outcome.
EffectBody<A extends Object, E extends Object> = FutureOr<A> Function(EffectContext<E> use)
A lazy Effect body with access to contextual services and typed failures.
EffectCommandBuildWhen<A extends Object, E extends Object> = bool Function(EffectCommandState<A, E> previous, EffectCommandState<A, E> current)
Decides whether one state transition should rebuild the subtree.
EffectCommandChanged<A extends Object, E extends Object> = void Function(BuildContext context, EffectCommandState<A, E> state)
EffectCommandDefectListener<A extends Object> = void Function(BuildContext context, Object defect, StackTrace stackTrace, A? previous)
EffectCommandFailureListener<A extends Object, E extends Object> = void Function(BuildContext context, E error, A? previous)
EffectCommandIdleListener<A extends Object> = void Function(BuildContext context, A? previous)
EffectCommandInterruptedListener<A extends Object> = void Function(BuildContext context, A? previous)
EffectCommandListenWhen<A extends Object, E extends Object> = bool Function(EffectCommandState<A, E> previous, EffectCommandState<A, E> current)
Decides whether a transition should be delivered to a listener.
EffectCommandObserver = void Function(EffectCommandTransition transition)
Observes transitions from every command created by one EffectCommands instance.
EffectCommandPolicyObserver = void Function(EffectCommandPolicyEvent event)
Observes policy decisions from one or more Commands.
EffectCommandRunningListener<A extends Object> = void Function(BuildContext context, A? previous)
EffectCommandSelectedWidgetBuilder<S> = Widget Function(BuildContext context, S selected, Widget? child)
Builds a subtree from a selected Command value.
EffectCommandSelectionEquals<S> = bool Function(S previous, S current)
Compares previous and current selected values.
EffectCommandSnapshotSelector<A extends Object, E extends Object, S> = S Function(EffectCommandSnapshot<A, E> snapshot)
Selects one strongly typed value from a read-only Command snapshot.
EffectCommandStateObserver<A extends Object, E extends Object> = void Function(EffectCommandState<A, E> state)
Observes every visible state published by one command.
EffectCommandStateSelector<A extends Object, E extends Object, S> = S Function(EffectCommandState<A, E> state)
Selects one strongly typed value from a Command state.
EffectCommandSuccessListener<A extends Object> = void Function(BuildContext context, A value)
EffectCommandWidgetBuilder<A extends Object, E extends Object> = Widget Function(BuildContext context, EffectCommandState<A, E> state, Widget? child)
Builds a Widget from the current typed command state.
ReleaseFailure = ({Object error, StackTrace stackTrace})
A finalizer failure captured while closing a Scope.
ResolverBackendDisposalProbeFactory = ResolverBackendDisposalProbe Function()
Creates a backend with backend-specific disposal instrumentation.
ResolverBackendTestFactory = ResolverBackend Function()
Creates a fresh backend for one compatibility scenario.
ResourceAcquire<T extends Object> = FutureOr<T> Function(Services services)
Creates a resource using services already available in the module.
ResourceRelease<R extends Object> = FutureOr<void> Function(R resource, Exit<Object, Object> exit)
Releases a resource with the outcome that closed its owning Scope.
Result<S extends Object> = ResultDart<S, Exception>
A typedef for a Result that simplifies the usage of ResultDart with Exception as the default failure type.
RuntimeObserverErrorHandler = void Function(RuntimeObserverError error)
Reports failures raised by RuntimeObserver callbacks.
ScopeFinalizer = FutureOr<void> Function(Exit<Object, Object> exit)
A cleanup callback registered with a Scope.
TestCleanupRegistrar = void Function(Future<void> cleanup())
Registers an asynchronous cleanup callback with the surrounding test runner.

Exceptions / Errors

ActiveTestExecutionsException
Raised when a test leaves managed physical work active.
BetterEffectTestExpectationException
Framework-independent failure used by typed Exit extractors.
CompositeDefect
Preserves a primary defect together with another defect raised during cleanup.
DuplicateEffectCommandListenerDeliveryException
DuplicateServiceBindingException
Thrown when a Module contains more than one binding for the same service.
EffectCommandPolicyProbeExpectationException
EffectCommandProbeDisposedException
Raised when a disposed probe is reused.
EffectCommandProbeExpectationException
Raised when a probe state sequence differs from the expectation.
EffectCommandProbeTimeoutException
Raised when no matching Command state appears within a timeout.
EffectCommandTestExpectationException
RecordingRuntimeObserverDisposedException
Raised when a disposed recorder is used again.
ResolverBackendContractException
Aggregate failure raised by verifyResolverBackendContract.
ResolverBackendContractViolation
One failed contract assertion.
ResolverBackendOverlayUnsupportedException
Reported when a custom backend cannot create an isolated child overlay.
ResourceAcquisitionException
Identifies the Module resource whose acquisition failed.
RuntimeClosedException
Thrown when an operation is attempted after a Runtime stops accepting work.
RuntimeEventWaitTimeoutException
Raised when RecordingRuntimeObserver.next did not observe a matching event.
ScopeClosedException
Thrown when new work is added to a Scope after closing starts.
ScopeReleaseException
Aggregates one or more defects raised while releasing scoped resources.
TestEventSequenceException<T extends Object>
TestGateAlreadyCompletedException