mocktail 0.0.1-dev.1 copy "mocktail: ^0.0.1-dev.1" to clipboard
mocktail: ^0.0.1-dev.1 copied to clipboard

outdated

A Dart mocking library which simplifies mocking with null safety support and no manual mocks or code generation.

example/main.dart

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

// A Real Cat class
class Cat {
  String sound() => 'meow!';
  int lives = 9;
}

// A Mock Cat class
class MockCat extends Mock implements Cat {}

void main() {
  group('Cat', () {
    late Cat cat;

    setUp(() {
      cat = MockCat();
    });

    test('example', () {
      // Stub a method before interacting with the mock.
      when(cat).calls('sound').thenReturn('purr');

      // Interact with the mock.
      expect(cat.sound(), 'purr');

      // Verify the interaction occurred.
      verify(cat).calls('sound').times(1);
    });
  });
}
973
likes
0
pub points
99%
popularity

Publisher

verified publisherfelangel.dev

A Dart mocking library which simplifies mocking with null safety support and no manual mocks or code generation.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on mocktail