Cas*_*iel 8 flutter flutter-test
所以我正在尝试对一个块进行单元测试
我的测试很简单
test("When loading patients, bloc should emmit [Loading], [OwnersLoaded]", (){
//arrange
var owners = [Owner(id: "TestId")];
when (mockPatientsRepository.getOwnersForCurrentPractice()).thenAnswer((_)=>Future.value(owners));
final List<PatientsState> expected = [patientsBloc.initialState, Loading(), OwnersLoaded(owners)];
//assert later
expectLater(patientsBloc, emitsInOrder(expected));
//act
useCase.getPatients();
});
Run Code Online (Sandbox Code Playgroud)
所有者确实覆盖了等于和哈希
我的错误信息
Expected: should do the following in order:
• emit an event that <Instance of 'InitialPatientsState'>
• emit an event that <Instance of 'Loading'>
• emit an event that <Instance of 'OwnersLoaded'>
Actual: <Instance of 'PatientsBloc'>
Which: emitted • Instance of 'InitialPatientsState'
• Instance of 'Loading'
• Instance of 'OwnersLoaded'
which didn't emit an event that <Instance of 'InitialPatientsState'>
Run Code Online (Sandbox Code Playgroud)
所以它说它发出了初始状态,但没有发出?
| 归档时间: |
|
| 查看次数: |
502 次 |
| 最近记录: |