stub 0.2.0+0 copy "stub: ^0.2.0+0" to clipboard
stub: ^0.2.0+0 copied to clipboard

outdated

A Dart micro-package to help writing tests stubbing methods

example/README.md

Example #

import 'package:stub/stub.dart';
import 'package:test/test.dart';

mixin Foo<T> {
  T foo();
  T baz();
  T bar();
}

class FooStub<T> extends Stub<T> implements Foo<T> {
  @override
  T bar() => throw UnimplementedError();
  @override
  T baz() => throw UnimplementedError();
  @override
  T foo() => stub();
}

void main() {
  group('`Stub` test', () {
      final fooStub = FooStub<int>();
      const data = 1;
    test(
        'GIVEN `stub != null`'
        'WHEN Foo.foo is called '
        'THEN returns `result`', () {
      fooStub.reset;
      fooStub.result = () => data;
      expect(
        fooStub.foo(),
        data,
        reason: '`Foo.foo` should match `data`',
      );
    });
  });
}

you may directly look at the tests for a more comprehensive example

3
likes
0
pub points
7%
popularity

Publisher

verified publisheryakforward.com

A Dart micro-package to help writing tests stubbing methods

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on stub