Skip to main content

dactor_test 2.0.0 copy "dactor_test: ^2.0.0" to clipboard
dactor_test: ^2.0.0 copied to clipboard

Test utilities for the Dactor actor system - TestActorSystem and TestProbe

example/dactor_test_example.dart

import 'package:dactor/dactor.dart';
import 'package:dactor_test/dactor_test.dart';
import 'package:test/test.dart';

class Echo extends Actor {
  @override
  Future<void> onMessage(dynamic message) async {
    context.sender?.tell('echo: $message');
  }
}

void main() {
  late TestActorSystem system;
  setUp(() => system = TestActorSystem());
  tearDown(() => system.shutdown());

  test('echoes to the sender', () async {
    final probe = await system.createProbe();
    final echo = await system.spawn('echo', () => Echo());

    // The probe is the sender, so the reply comes back to it.
    probe.send(echo, 'hello');
    await probe.expectMsg('echo: hello', timeout: const Duration(seconds: 1));
  });
}
0
likes
160
points
118
downloads

Documentation

API reference

Publisher

verified publisherwerkswinkel.com

Weekly Downloads

Test utilities for the Dactor actor system - TestActorSystem and TestProbe

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dactor, test

More

Packages that depend on dactor_test