Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this video we are going to see how we can write tests for our model classes and we are going to use
the job class as an example so I can open the job file over here and I'm going to move it to the right
window.
And in particular we are interested in writing tests for that from map and to map methods that we used
to read and write.
They thought we'd faster and I think it's especially important to have test coverage for data that we
read from faster because Firestone is a schema less database where the data is not structured.
So adding tests to model classes is a good way to ensure that our client application processes the data
correctly.
So our next step is to create a new Dart file called job on this court fast.
And here we are going to add some tests for this class.
So let's start by importing the third test and then we can out the void Main method.
And in here we can create a new group called from map.
And this is because we want to test this method first.
And the first test that we want to write should check that if we get a new data argument then we return
no.
So we're going to write a test called normal data and inside the test body we can write final job equals
job dot from month with no.
And then for example ABC has a document idea and we need to import job as well.
And then we can have our next fact we job equals no like this.
And I'm not going to run this but I can assure you that this test will pass.
Next we need architects to check that when we pass a map.
We've done name and our rate per hour.
Then our job is created and the corresponding properties are set.
So here we could create a new test named job with all properties like this and then we could create
a final job equals job dot from map.
And here we could pass a map with the name of for example blogging and a grade per hour of 10.
And we could pass a document I.D. of ABC like this and then we need to write our expectations.
So here we could type expect and then job dot name to be equal to blogging and then we could also expect
that job growth rate per hour is equal to 10.
And finally job dot deem to be equal to a b c.
And at this stage we could run the tests and as we can see we got success.
However I think that these three expectations are quite verbose.
And instead I would prefer to write something like expect with job and then equal to job with name of
blogging and rate per hour of then and job and I need to be a b c like this.
So with this change I can remove the previous lines and then can run the test again.
And as we can see this time we get an error saying that we expected an instance of job and the actual
value was also an instance of job.
So let's try to understand this in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.