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
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 the last video we added our new test to our state validator and in general one of the goals of the
unit testing is that we should test our objects with all possible inputs.
And while these may not be practical in all cases I think there is one more test that we could add to
this file and that is to check what happens when we pass a no string to this method.
However when we created the known empty string validator we haven't actually decided what should happen
when the input string is no.
So by writing these extra test we are actually looking at one edge case that we have not considered
before and we could approach this in two ways.
We could say that passing a new string is not about this scenario and we would expect the app to throw
an assertion at runtime or we could decide that a new string should be accepted and that this method
to return false.
In this case.
And for this specific case I propose that we take the second option and we allow unknown string to be
passed.
So what we are going to do is throw out our new test by copy pasting the previous method like this and
here we can update that description to no string.
And we are going to pass no two is valid and we want the expectation to be false and then we can run
this test and in the console log we see that we get a narrow because we try to call is not empty on
unknown object.
So let's open the string money that are once again.
And here we can fix this by adding a check that says if value is no then return false like this and
then we can run the test once again
and this time we can see that the test has passed.
By the way this icon on Android Studio is still red but I have found that this is a bug in Android Studio
and we can tell that the test is passed because this check mark is green over here.
In summary we have written some tests for this class and this forced us to think about all the possible
inputs and in the process of doing this we have discovered a problem when passing new values and to
address this.
We have written a failing test first and then we have fixed our known empty string validate or class
which made our test go green again.
And this is a process that is often used when writing tests because we can start by writing a failing
test and then we can write the code that makes that test go green and the result of this is that our
code is more robust and it also has better test coverage so you can consider using this approach as
you write your own classes and tests.
Okay.
So let's continue on the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.