diff --git a/packages/mocktail/lib/mocktail.dart b/packages/mocktail/lib/mocktail.dart index 6585d2f..d38a061 100644 --- a/packages/mocktail/lib/mocktail.dart +++ b/packages/mocktail/lib/mocktail.dart @@ -2,7 +2,8 @@ /// with null safety support and no manual mocks or code generation. library mocktail; -export 'src/fake.dart' show Fake; +// ignore: deprecated_member_use +export 'package:test_api/fake.dart' show Fake; export 'src/mocktail.dart' show Mock, diff --git a/packages/mocktail/lib/src/fake.dart b/packages/mocktail/lib/src/fake.dart deleted file mode 100644 index 09ab393..0000000 --- a/packages/mocktail/lib/src/fake.dart +++ /dev/null @@ -1,18 +0,0 @@ -/// A fake is an object that can be used as a drop-in replacement for another -/// object in tests. Unlike a mock, it does not have any expectations about how -/// it is used, and it does not record how it is used. It simply has a -/// `noSuchMethod` implementation that does not throw a -/// [NoSuchMethodError], but instead throws an [UnimplementedError] -/// with the name of the invoked method. -/// -/// Fields and methods that are exercised by the code -/// under test should be manually overridden in the implementing class. -/// -/// A fake does not have any support for verification or defining behavior from -/// the test so it cannot be used as a mock. -abstract class Fake { - @override - dynamic noSuchMethod(Invocation invocation) { - throw UnimplementedError(invocation.memberName.toString().split('"')[1]); - } -} diff --git a/packages/mocktail/pubspec.yaml b/packages/mocktail/pubspec.yaml index 691f93e..a24e9db 100644 --- a/packages/mocktail/pubspec.yaml +++ b/packages/mocktail/pubspec.yaml @@ -11,7 +11,8 @@ environment: dependencies: collection: ^1.15.0 matcher: ^0.12.15 + test_api: '>=0.2.1 <0.7.0' dev_dependencies: - meta: ^1.3.0 + meta: ^1.10.0 test: ^1.24.6 diff --git a/packages/mocktail/test/src/fake_test.dart b/packages/mocktail/test/src/fake_test.dart deleted file mode 100644 index c8bed4a..0000000 --- a/packages/mocktail/test/src/fake_test.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:mocktail/mocktail.dart'; -import 'package:test/test.dart'; - -void main() { - group(Fake, () { - late _MyClass instance; - - setUp(() { - instance = _MyFakeClass(); - }); - - test('method invocation', () { - expect(() => instance.f(), throwsUnimplementedError); - }); - test('getter', () { - expect(() => instance.x, throwsUnimplementedError); - }); - test('setter', () { - expect(() => instance.x = 0, throwsUnimplementedError); - }); - test('operator', () { - expect(() => instance + 1, throwsUnimplementedError); - }); - }); -} - -class _MyClass { - void f() {} - - int get x => 0; - - set x(int value) {} - - int operator +(int other) => 0; -} - -class _MyFakeClass extends Fake implements _MyClass {}