ZenTestMode class
Test mode utilities for easy mocking and test setup
Provides a fluent API for setting up test dependencies and creating isolated test scopes.
Example:
testWidgets('login flow', (tester) async {
Zen.testMode()
.mock<AuthService>(FakeAuthService())
.mock<ApiClient>(MockApiClient());
await tester.pumpWidget(MyApp());
// test...
});
Constructors
- ZenTestMode()
-
Get the singleton test mode instance
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearQueryCache(
) → ZenTestMode - Clear query cache (useful between tests)
-
isolatedScope(
{String? name}) → ZenScope - Create an isolated test scope
-
mock<
T> (T instance, {String? tag}) → ZenTestMode - Replace a dependency with a mock/fake implementation
-
mockAll(
Map< Type, dynamic> mocks) → ZenTestMode - Mock multiple dependencies at once
-
mockLazy<
T> (T factory(), {String? tag, bool alwaysNew = false}) → ZenTestMode - Replace a dependency with a factory function
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Reset all mocks and return to normal mode
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited