Confusing failure with nested mocks
- 主要语言
- Dart
- 星标
- 702
- 派生
- 88
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。