felangel / felangel/mocktail

Confusing failure with nested mocks

Đang mở
#204 6 bình luận 1 reaction 1 người được giao Được @felangel nhận Xem trên GitHub
enhancement
Ngôn ngữ chính
Dart
Star
702
Fork
88
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I meant to file this a few weeks ago, sorry.

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

class One {
final Two two = Two();
}

class Two {
final String three = '';
}

class _MockOne extends Mock implements One {}

class _MockTwo extends Mock implements Two {}

void main() {
test('nested mocks', () {
final one = _MockOne();
final two = _MockTwo();
when(() => one.two).thenReturn(two);
when(() => one.two.three).thenReturn('three');
expect(one.two.three, 'three');
});
}
```

```
00:02 +0 -1: nested mocks [E]
type 'String' is not a subtype of type 'Two'
test/foo_test.dart 12:7 _MockOne.two
test/foo_test.dart 22:16 main.
```

That's a better error than I remember (I remember it being silent?) But it's still pretty confusing. Feel free to close.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.