1
resposta

verify na lista de contatos depois de adicionar o contact

Conforme foi mostrado no vídeo realizei o verify do mockContactDao.findAll e também ajustei o ContactsList para StatefulWidget mas mesmo assim recebo o erro de que o verify não encontrou o acesso ao findAll, o que pode estar faltando?

Erro: Testing started at 16:28 ... /Users/douglaspereira/Documents/flutter/bin/flutter --no-color test --machine test/save_contact_flow.dart ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following TestFailure object was thrown running a test: No matching calls. All calls: [VERIFIED] MockContactDao.findAll(), [VERIFIED] MockContactDao.save(Contact{id: 0, name: Alex, accountNumber: 1000}) (If you called verify(...).called(0);, please instead use verifyNever(...);.)

When the exception was thrown, this was the stack:

#0 fail (package:test_api/src/frontend/expect.dart:153:30)

#1 _VerifyCall._checkWith (package:mockito/src/mock.dart:648:7)

#2 _makeVerify. (package:mockito/src/mock.dart:935:18)

#3 main. (file:///Users/douglaspereira/Desktop/curso-flutter/flutter-tests-initial-project/test/save_contact_flow.dart:62:11)

#4 testWidgets.. (package:flutter_test/src/widget_tester.dart:140:29)

#5 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:706:19)

#8 TestWidgetsFlutterBinding._runTest (package:flutter_test/src/binding.dart:686:14)

#9 AutomatedTestWidgetsFlutterBinding.runTest. (package:flutter_test/src/binding.dart:1086:24)

#15 AutomatedTestWidgetsFlutterBinding.runTest (package:flutter_test/src/binding.dart:1083:15)

#16 testWidgets. (package:flutter_test/src/widget_tester.dart:133:24)

#17 Declarer.test... (package:test_api/src/backend/declarer.dart:171:27)

#18 Invoker.waitForOutstandingCallbacks. (package:test_api/src/backend/invoker.dart:242:15)

#23 Invoker.waitForOutstandingCallbacks (package:test_api/src/backend/invoker.dart:239:5)

#24 Declarer.test.. (package:test_api/src/backend/declarer.dart:169:33)

#29 Declarer.test. (package:test_api/src/backend/declarer.dart:168:13)

#30 Invoker._onRun.... (package:test_api/src/backend/invoker.dart:392:25) (elided 31 frames from class _FakeAsync, class _RawReceivePortImpl, class _Timer, dart:async, dart:async-patch, and package:stack_trace)

The test description was: Should save a contact ════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above. The test description was: Should save a contact

1 resposta

Oi Douglas, tudo bem ?

Cara eu vi que sua dúvida é um pouco antiga, será que tu já resolveu ? Se sim pode compartilhar conosco ?