All language subtitles for 382 Writing the first unit test.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,510 --> 00:00:06,600 In this video we will start looking at how we can write unit tests for our application and when we work 2 00:00:06,600 --> 00:00:07,800 with flutter projects. 3 00:00:07,800 --> 00:00:14,820 There is a convention that all tests are stored inside a folder called Test which is located at the 4 00:00:14,820 --> 00:00:20,060 root of our project and if we open this folder we can find a single file called. 5 00:00:20,070 --> 00:00:27,240 We did that dot dart and this is an example we did test that is added when we create a new flatter project 6 00:00:27,570 --> 00:00:28,620 and we will look at. 7 00:00:28,620 --> 00:00:30,430 We did tests later on. 8 00:00:30,450 --> 00:00:35,220 So for now we can go ahead and delete this file. 9 00:00:35,220 --> 00:00:38,010 Next we want to create our first unit test. 10 00:00:38,370 --> 00:00:43,240 And since we already have a complete up we need to choose what we want to test. 11 00:00:43,380 --> 00:00:46,230 And I suggest that we start with something simple. 12 00:00:46,260 --> 00:00:52,470 For example we could open the signing folder and in here we have these validators that that file. 13 00:00:52,710 --> 00:00:58,540 And as we can see we have unknown empty string validator class that implements one method. 14 00:00:58,620 --> 00:01:03,480 And what this does is return true if the input string is not empty. 15 00:01:04,050 --> 00:01:08,430 So I think this class is a good candidate for our first test. 16 00:01:08,490 --> 00:01:10,890 So we're going to select the test folder. 17 00:01:10,950 --> 00:01:19,390 And here we can create a new Dart file called Mali datas on this core test. 18 00:01:19,580 --> 00:01:20,750 They'll start. 19 00:01:20,940 --> 00:01:23,310 And next we can start writing some code. 20 00:01:23,310 --> 00:01:30,330 And the first thing that we want to do is to create that void Main method which is the entry point for 21 00:01:30,360 --> 00:01:32,060 all the tests in this file. 22 00:01:32,400 --> 00:01:41,700 And the other thing that we need to do is to import a file called flatter test like this. 23 00:01:41,700 --> 00:01:47,970 And now that we have done this we can start writing our first test and we do this by calling a method 24 00:01:47,970 --> 00:01:49,500 called test. 25 00:01:49,830 --> 00:01:59,130 And this takes up description which is a string and also closure which represents the body of our test. 26 00:01:59,130 --> 00:02:01,280 But what is it that we want to test. 27 00:02:01,290 --> 00:02:01,950 Exactly. 28 00:02:02,340 --> 00:02:05,790 Well we can open the non empty string validate or class. 29 00:02:05,790 --> 00:02:12,630 And I think our good first test would be to verify that the IS valid method returns true when we pass 30 00:02:12,670 --> 00:02:13,640 an on empty string. 31 00:02:14,100 --> 00:02:18,240 So let's implement this back to our test file. 32 00:02:18,300 --> 00:02:18,830 We cannot. 33 00:02:18,870 --> 00:02:28,140 A description that says no an empty string and inside the body I'm going to order final validate all 34 00:02:28,890 --> 00:02:35,420 equals an empty string pollinator like this. 35 00:02:35,420 --> 00:02:38,620 And I need to remember to import this. 36 00:02:39,080 --> 00:02:41,800 And then we want to write an expectation. 37 00:02:42,050 --> 00:02:45,890 So I'm going to type in some code and then I'm going to explain it. 38 00:02:45,920 --> 00:02:54,900 So here I can I expect and then validator dot is valid with test. 39 00:02:55,550 --> 00:02:58,670 And then through like this. 40 00:02:58,700 --> 00:02:59,000 Okay. 41 00:02:59,030 --> 00:03:00,910 So how does this work. 42 00:03:00,920 --> 00:03:07,490 Well by adding this code to expect we are writing an assertion that checks that the value returned by 43 00:03:07,490 --> 00:03:12,620 the first argument matches the value that we pass to the second argument. 44 00:03:12,620 --> 00:03:19,460 And this entire expression is something that we can almost read in plain English because we are expecting 45 00:03:19,490 --> 00:03:23,920 that validator that is valid means test is true. 46 00:03:24,710 --> 00:03:28,550 And now that we have written our first test we can execute it. 47 00:03:28,550 --> 00:03:30,580 So let's do that in the next video. 4522

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.