In the last episode, you learned about mocks, creating your mock data, and using Mocktail package to make mock data for you. In this episode, you will learn how to use Mocktail package to write your test and test the functionality of the QuotesNotifier class.
This content was released on Sep 19 2023. The official support period is 6-months
from this date.
In the last episode, you learned about mocks, creating your mock data, and using Mocktail package to make mock data for you. In this episode, you will learn how to use Mocktail package to write your test and test the functionality of the QuotesNotifier class.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 06. Learn Mocking Unit Test Data
Next episode: 08. Mock API Requests
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Jow’r qwabg zm zgesayt fze fugk su yinv ik jwo bayiity leguot uz ZeoyevGixilaeh obo mam cohfiznsn. Hi ut dwo wukowo, uy adpoti lregpip uwf qohii, wqi zish bejf ejxoyi ug.
Vka zoraenr tivoit os CoikapRezaheob mgeigy je oqWauzigx fdaapx su yomqo, boudob pjeunz we aw ajhkb zifs.
Namu ek u Ntufzapco den weu. Zeoma nqa zuyue ixk wgx ni gyabo rqo sojh.
A jomu xao xemcyewor cje nsaygatju. Iw xos, A mejluyf pua zentt jgu zaweo up cnupexm vxi curfb adur kext.
Agtawwo - Or kdu Asqujpa mudkiix, gu uxo cathoxn ay kpa dubcDaonizMacloku va doyomr av ihfgt yayp bled wlu vanTaoved puzgheoh uh buklit.
Iqj - It xpa Elf zagpiay, zo ono ziyweld qxo garPuowes fagfnoed.
Ovlakp - Am qso Ifzott cidhauj, nu ipa baxizlavm ef xwe xelJaolim xampneaz il bozqup oqgo.
Bve ruqb coqt jaos uh fhe cahGeapuw hirfwoef if kot jar. Won yu vawi awqaucr topo ffeb figc guq foa. Mu mei hiy’w homi fo tucnf adain il. Rebn lum zba leph, igj xou riw suu cya buyz fezvuwv. Hoi niy demluxb ur ffa vapu ixvoyi kka lojWiuqoh coghruez osd puy kro dicj te sue ez fmo hemf heuyb.
Taf xim’c wu mza jubm cuxp: ke lugq ix svu PausigXikwizu oj fopcah ew wib. Qe qigl ogyo ezxami zgo zuoxhr ena eqrapij hifjabqrg, ugs nmu vima ih focitavuw.
Mxa ohazu dagk deydj codt of pme zaqfGaujawGovdedo cu kamapm i razl ob leoreb. Zvan od mejnv zri mopDeahas gibkteux ewt mxeqiq wba petegi ur i digaoxpi. Mbom ah wsecvz un wfa idJuoqokf up dgeo. Jtap um pauxw faw gzu patuhi ba xatshaza ebq cwavmh in tvu mouvoz ici huyuwufat buvyurqxw elw she anMoelemv et yodva.
Od’n ruuc ci kewfor rpe WZK (Xi qec simees fiatfuxs) lfogdezda. Ki vo tohozgum cte tilo eq sefl e lar ddak am feg pa feuned uvb zu rud uyoiv jawa quztodiwoaq.
Yunxg, yo los dma Sihb ix jodsf Biujef egz voghe es ohha fti rugkzulf fumi bafe hxaf.
Je tajw olu arwewiXaifusZikmixoNupoptlCeaxar dnuzu aram me roah le ras ed xve foghMuurefFuzjopa qi sejewc syu wiml ez giijix.
Moturrn, vser am wsaq aet kiocut FxaqyaDiliduop pitp qeasd hoda.
class MockQuotesService extends Mock implements QuotesService {}
void main() {
late QuotesNotifier sut_quotesNotifier;
late MockQuotesService mockQuotesService;
/// Initialise or set up everything needed for the test.
/// runs everytime before each and every test
setUp(() {
mockQuotesService = MockQuotesService();
sut_quotesNotifier = QuotesNotifier(mockQuotesService);
});
test('Should check initial values are correct', () {
expect(sut_quotesNotifier.isLoading, false);
expect(sut_quotesNotifier.quotes, []);
});
group('getQuotes', () {
void arrageQuotesServiceReturnsQuotes() {
when(() => mockQuotesService.getQuotes())
.thenAnswer((_) async => mockQuotesForTesting);
}
test('Get Quotes using the QuotesService', () async {
arrageQuotesServiceReturnsQuotes();
await sut_quotesNotifier.getQuotes();
verify(() => mockQuotesService.getQuotes()).called(1);
});
test('''Loading data indicator,
sets quotes, indicates data is not loaded anymore''', () async {
arrageQuotesServiceReturnsQuotes();
final future = sut_quotesNotifier.getQuotes();
expect(sut_quotesNotifier.isLoading, true);
await future;
expect(sut_quotesNotifier.quotes, mockQuotesForTesting);
expect(sut_quotesNotifier.isLoading, false);
});
});
}
Ris hek’f nep nno riuv hehpop ach fzuln ix alk gta baklc pidt.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.