Afrikaans
Akan
Albanian
Amharic
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
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this video we will start looking at how we can write unit tests for our application and when we work
with flutter projects.
There is a convention that all tests are stored inside a folder called Test which is located at the
root of our project and if we open this folder we can find a single file called.
We did that dot dart and this is an example we did test that is added when we create a new flatter project
and we will look at.
We did tests later on.
So for now we can go ahead and delete this file.
Next we want to create our first unit test.
And since we already have a complete up we need to choose what we want to test.
And I suggest that we start with something simple.
For example we could open the signing folder and in here we have these validators that that file.
And as we can see we have unknown empty string validator class that implements one method.
And what this does is return true if the input string is not empty.
So I think this class is a good candidate for our first test.
So we're going to select the test folder.
And here we can create a new Dart file called Mali datas on this core test.
They'll start.
And next we can start writing some code.
And the first thing that we want to do is to create that void Main method which is the entry point for
all the tests in this file.
And the other thing that we need to do is to import a file called flatter test like this.
And now that we have done this we can start writing our first test and we do this by calling a method
called test.
And this takes up description which is a string and also closure which represents the body of our test.
But what is it that we want to test.
Exactly.
Well we can open the non empty string validate or class.
And I think our good first test would be to verify that the IS valid method returns true when we pass
an on empty string.
So let's implement this back to our test file.
We cannot.
A description that says no an empty string and inside the body I'm going to order final validate all
equals an empty string pollinator like this.
And I need to remember to import this.
And then we want to write an expectation.
So I'm going to type in some code and then I'm going to explain it.
So here I can I expect and then validator dot is valid with test.
And then through like this.
Okay.
So how does this work.
Well by adding this code to expect we are writing an assertion that checks that the value returned by
the first argument matches the value that we pass to the second argument.
And this entire expression is something that we can almost read in plain English because we are expecting
that validator that is valid means test is true.
And now that we have written our first test we can execute it.
So let's do that in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.