monart_testing library

Testing utilities for monart.

Import this library in your test files alongside package:monart/monart.dart to access mockService, clearServiceMocks, MockService, haveSucceededWith, and haveFailedWith:

import 'package:monart/monart.dart';
import 'package:monart/monart_testing.dart';

This entry point is intentionally separate from the main library so that test-only code is never bundled into production builds.

Classes

FailureMatcher
Matcher returned by haveFailedWith. Chain andContext to also assert the context.
MockService<Value>
A test-only ServiceBase that returns a predetermined Result.
SuccessMatcher
Matcher returned by haveSucceededWith. Chain andValue to also assert the value.

Functions

clearServiceMocks() → void
Removes all interceptors registered with mockService.
haveFailedWith(Object? outcomes) FailureMatcher
Matches a Result that is a Failure with the given outcomes.
haveSucceededWith(Object? outcomes) SuccessMatcher
Matches a Result that is a Success with the given outcomes.
mockService<MockedService extends ServiceBase<Object?>>(Result result) → void
Intercepts all ServiceBase.call invocations of type MockedService and returns result instead of executing ServiceBase.run.