shard_test library

Public testing utilities for the shard package.

Import from your test code:

import 'package:shard/shard_test.dart';

This entry point is intentionally separate from package:shard/shard.dart so production builds do not link the test utilities. Nothing in lib/shard.dart's import graph imports this file.

Classes

FakeCacheService
An in-memory CacheService implementation for use in tests.
FakeStateStorage
An in-memory StateStorage implementation for use in tests.
MockShardObserver
A ShardObserver that records all events for inspection in tests.
ObservedChange<T>
A single observed onChange event captured by MockShardObserver.
ObservedError
A single observed onError event captured by MockShardObserver.
ShardTester<T>
A helper for testing Shard subclasses by capturing emissions, waiting for specific states, and asserting state sequences.

Functions

shardTest<S extends Shard<T>, T>({required S build(), required List<T> expect, Future<void> act(S shard)?, Duration timeout = const Duration(seconds: 1)}) Future<void>
A thin declarative wrapper around ShardTester.

Exceptions / Errors

ShardAssertionError
Thrown by ShardTester when an assertion fails.
ShardTimeoutError
Thrown by ShardTester when an async wait exceeds its timeout.