What is Unit Testing, Why We Use It, and Sample Test Cases

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025
  • Unit testing is a huge part of Software Development, however it's one of those topics that is not easy to understand until you are given some proper examples and context. In this video, we explore a simple test case that prevents some embarrassing mistakes from being introduced into our production application.
    Enjoy.
    Instagram Firebase Course
    www.letsbuildt...
    Time Ago Algorithm Explanation
    • Swift: How to Display ...
    Facebook Group
    / 1240636442694543
    iOS Basic Training Course
    www.letsbuildt...
    Follow me on Twitter: / buildthatapp

Комментарии • 234

  • @seanallen
    @seanallen 7 лет назад +226

    This is a very underserved topic. Thanks for putting out a video on it. All devs need to know this.

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +32

      Testing is definitely a topic that deserves attention from iOS developers. It's very interesting all the flaws you can find by just testing your own code.

    • @rumitification
      @rumitification 6 лет назад +3

      Thanks for the video Brian!
      Posting it here as both you and Sean post tutorials very actively.
      If you guys get a chance, could you please post a video on how to write cases to test HTTP requests and responses using something like OHTTPStubs?
      Thank you for all your posts. Cheers!

    • @aleksplats
      @aleksplats 5 лет назад

      rumitification good request)

    • @pappukhan7353
      @pappukhan7353 5 лет назад

      Mera number hai koi

    • @demoncoco1386
      @demoncoco1386 4 года назад

      Thanks for the video

  • @JoseSalazar-cj3gd
    @JoseSalazar-cj3gd 4 года назад +1

    I know this video is three years old, but it's very educational about this topic of unit testing. Thank you!

  • @mattlarsen
    @mattlarsen 3 года назад

    Fantastic and quick introduction to something that is whispered in hushed tones amongst junior developers.

  • @adamsmidov1014
    @adamsmidov1014 3 года назад

    First time I see such a simple way for the explanation. Great!

  • @thomaspatouillaud9063
    @thomaspatouillaud9063 7 лет назад +12

    Brian Voong you are to iOS what Andrew Ng is for Maching Learning : concise, clear, and brilliant !

  • @marcaupont9145
    @marcaupont9145 7 лет назад

    Very nice! I like the new effects! It gives your videos a polished look

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      Thanks Marc, I'm still figuring my way out around Adobe Premiere.

  • @jross3r
    @jross3r 7 лет назад +1

    First I heard of built in test functions. Reminds me of sales force development. Thank you.

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Yep, all enterprise companies have very robust testing infrastructure that produces reliable code for their customers that are paying millions.

  • @utberoxsobad
    @utberoxsobad 7 лет назад +4

    Yes please! Can you make unit testing videos! Especially for networking and requests and model objects as well!!

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +5

      Yeah I think I'll make a unit test video on network requests.

  • @anshuparihar3654
    @anshuparihar3654 7 лет назад

    Nice, elaborate and to the point. Need some advance examples but for gaining basic understanding this is superb.

  • @sawyerburnett8319
    @sawyerburnett8319 6 лет назад +2

    I don't use swift, but this was a really helpful primer on unit tests! I've worked at too many companies that don't see the value in them, so I'm working hard to start integrating them into our code base

  • @maklasik
    @maklasik 7 лет назад

    Not even coding in swift, but very interesting to watch. This channel is awesome. Talking about very important stuff for newbies. Much appreciated

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      Yeah this channel goes into more useful advanced topics that beginners should be aware of.

  • @ChordToday
    @ChordToday 6 лет назад

    Not aa iOS programmer here but your video explanation is so clear that I understand the concept anyway. Thank you!

  • @ehawkins730
    @ehawkins730 7 лет назад +1

    Perfect timing as always! Thank you Brian...much appreciated!

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      Perfect timing? Exam? Job interview? You've piqued my interest.

    • @ehawkins730
      @ehawkins730 7 лет назад

      Lets Build That App Hey, Brian...this week's application assignment for school was creating an app that included UITest...Unfortunately, my teacher isn't the greatest, so see outside resources to further my education. So it was perfect timing...as I follow all of your videos anyway.

    • @ivangutowski-smith6514
      @ivangutowski-smith6514 9 месяцев назад

      woah... from 7yrs ago instagram looked much the same !

  • @yonasstephen
    @yonasstephen 7 лет назад +1

    I never bother to learn what's that UnitTesting in Xcode for before. thanks for this! nicely put along with real-life example use case. now that you mentioned about Continous Integration, would be great if you could talk more about it in your next video, what tools you're using, and so on! Cheers

  • @septronic2010
    @septronic2010 7 лет назад +2

    I really liked this video. I am relatively new to testing, and find it a big challenge sometimes, especially when it comes to UI. Can you do some more complex testing tutorial as well please?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +2

      Yeah, there are many aspects of testing that can be applied to apps. I'll plan out some more videos on this.

  • @patrarus6097
    @patrarus6097 4 года назад

    Thanks, Brian. This was excellent!

  • @arkter9568
    @arkter9568 7 лет назад +1

    Some of your videos made me convince to learn programming. Thank you! :)

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      Hey thats great, hope you can see how simple it is when starting from scratch and building up a full product.

  • @HerbivoreJesus
    @HerbivoreJesus 7 лет назад

    Awesome video. Would love to see more about advanced unit testing

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Yeah, looking to put some more testing videos out.

  • @KelKrom
    @KelKrom 6 лет назад

    Excellent explanation!

  • @nikbelikov
    @nikbelikov 6 лет назад

    Very very clear! Thanks a lot!

  • @ladedadedaschlobonmeknob7850
    @ladedadedaschlobonmeknob7850 7 лет назад

    Sweet and right to the point.

  • @lorenzol6393
    @lorenzol6393 6 лет назад

    very nice and easy to follow

  • @elifarr
    @elifarr 5 лет назад

    Thanks a lot for clear and easy explanation!!!!

  • @fardayekahmed7878
    @fardayekahmed7878 6 лет назад

    very explanatory! thanks a lot.

  • @krutomjer
    @krutomjer 7 лет назад

    Great video Brian, I always thought that testing is tedious but this really makes it logical and appealing.

  • @brianleeson7402
    @brianleeson7402 6 лет назад +53

    Those pesky "junior developers"! Always breaking all the code that only I contribute to!

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад +10

      Indeed, 100% of bugs were never my fault :)

    • @KangJangkrik
      @KangJangkrik 4 года назад +3

      We can't fully blame junior developers unless we taught the concept and they didn't care

  • @elep4043
    @elep4043 4 года назад

    Thanks Brian!

  • @georgedubrik280
    @georgedubrik280 7 лет назад

    logically structured and informative presentation...thanks

  • @boxer3617
    @boxer3617 10 месяцев назад

    great work

  • @NurHidayatullah
    @NurHidayatullah 2 года назад

    thanks Brian, very usefull

  • @letaciogalvao9908
    @letaciogalvao9908 2 года назад

    Great, thanks a lot!!

  • @daniellaerachannel
    @daniellaerachannel 7 лет назад

    Amazing tut

  • @claudiopaulo3269
    @claudiopaulo3269 7 лет назад +1

    Hey Brian, how you doing? Always pushing us further, few code lines at time. Thanks for enlightening us, the mere mortal beings struggling to be relevant in this iOS universe. ;-)

  • @antoniodifrancesco4844
    @antoniodifrancesco4844 7 лет назад

    Wooow! I was waiting for this!! Super!

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +2

      Glad to have finally been able to make a video on Unit Testing as it's very important in the real world of software development.

  • @syedaurangzaib3861
    @syedaurangzaib3861 6 лет назад

    This topic is most important for us. I understand it clearly, because your teaching method is great :)
    please also make a video on test case for web services, api testing.
    I'm waiting for your kind video.

  • @chetanmrane
    @chetanmrane 7 лет назад

    super like this video and much needed....waiting for your UI unit test video

    • @chetanmrane
      @chetanmrane 7 лет назад

      i wish one day you also start teaching us android with same fun :) [but iOS - first love would remains first]
      BDW I am glad to tell you that whenever i do swipe on my smartphones...i notice diff apps and started dreaming coding the same programatically....Brian you have impacted so +vely....FAN OF YOUR WAY OF TEACHING

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      That's excellent, I also find myself trying to break down the apps I use into components I can build. It's a lot of fun.

  • @dudsaheb
    @dudsaheb 7 лет назад

    Very good explanation

  • @cro1114
    @cro1114 7 лет назад

    This tutorial is super!!. Thank you, I understand it very easy

  • @Tomhhw
    @Tomhhw 7 лет назад

    Hey Brian! Are you going to WWDC this year and planning to make a video about it?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Hey Tom, unfortunately my budget doesn't allow for a WWDC ticket. Perhaps I'll attend alt conf or some other nearby meetup.

  • @joycelu962
    @joycelu962 7 лет назад

    You are the best!! Thank you so much!!

  • @19glok
    @19glok 5 лет назад

    Thanks for creating this video.

  • @avoautomation8573
    @avoautomation8573 2 года назад

    Unit testing is a way of testing one unit of a software application. A unit is the smallest piece of software that is isolated and tested as an individual for functioning. Avo Automation provides the best automated testing platform for all types of software testing, including unit testing

  • @erikschaepers
    @erikschaepers 3 года назад

    good explanation

  • @oleksandrsamsonov3067
    @oleksandrsamsonov3067 7 лет назад +1

    You made it when I wanted to ask you to do such a video

  • @rl-pavel
    @rl-pavel 7 лет назад +2

    I would *love* to see more videos about Unit Testing! Keep it up, please!

  • @adithyavikram5426
    @adithyavikram5426 6 лет назад

    never knew test cases this much easier. Thanks for knowledge sharing
    5*

  • @KemaTheCreative
    @KemaTheCreative 2 года назад

    Hey do you think
    I can use this to make sure all my products are priced correctly on third party apps?

  • @shiju861
    @shiju861 6 лет назад

    Thanks for the video Sir!!

  • @ianman6
    @ianman6 7 лет назад

    Super, thanks! What code editor are you using for app development? Do you do other development (Android, web) and if so, do you use the same environment? Thanks!

  • @pkasetti
    @pkasetti 7 лет назад +1

    I really like this video!

  • @nadeasalvatore
    @nadeasalvatore 6 лет назад

    Thank you so much... This is very precious 😀

  • @kaanozdemir8666
    @kaanozdemir8666 7 лет назад

    Heeyy what's up Brain ! Hope you are doing well ! I love your videos. We are learning so much things.
    I want to ask one question.
    Will you do some videos about the image processing in swift or do you think ?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      When you say image processing are you referring to filters like instagram? I've written the code before and I could share it later on.

    • @kaanozdemir8666
      @kaanozdemir8666 7 лет назад

      Lets Build That App No, not like the instagram. Like using open cv, doing corner detection , tracking object, scanning documents etc. Because there are not lots of source about swift - opencv .

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      I see, I've never looked into opencv before, perhaps one day I'll do some research.

    • @kaanozdemir8666
      @kaanozdemir8666 7 лет назад

      Lets Build That App
      Okey, thank you Brain. we love you. You are awesome !

  • @presbytes
    @presbytes 7 лет назад

    Learned about Unit Tests and that you can create extensions on primitive types. I'm new to Swift haha. By the way, your content is awesome!

  • @swamiips
    @swamiips 7 лет назад +1

    I can say only one thing.. He is a swift god

  • @tsmithcad
    @tsmithcad 6 лет назад

    Your awesome man!

  • @siewtany1174
    @siewtany1174 7 лет назад

    Your videos are excellent and great on teaching Swift. Please continue your hard work! Truly appreciate. Are you gonna teach Android in the future? If not, any recommendations who has best teaching on Android?

  • @rebeloper
    @rebeloper 7 лет назад

    Awesome

  • @heri_prieto
    @heri_prieto 7 лет назад +2

    I have a second interview in about two hours, thanks for this video! Wish me luck!

  • @makwanbarzan7085
    @makwanbarzan7085 4 года назад

    Made this topic clear to me in a just few minutes. Many thanks!

  • @annamalairajj7705
    @annamalairajj7705 6 лет назад

    Thanks for the video. This enlightened us on why unit test required and how to write test cases. Could you teach us how to write UITests and Mocks?

  • @lennartphilipp6699
    @lennartphilipp6699 7 лет назад

    Could you make a video about your setup? I'm really curious what tech you're using. Love your videos btw ^^

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      My development setup or recording setup?

    • @lennartphilipp6699
      @lennartphilipp6699 7 лет назад

      Lets Build That App Both but I'd be more interested in your development setup

  • @crzyjocksstudio6015
    @crzyjocksstudio6015 3 года назад

    Which hardware is using in unit testing

  • @Zakawaka45
    @Zakawaka45 7 лет назад

    Could you do some Unit and UI testing tutorials?

  • @minchaejeong5010
    @minchaejeong5010 7 лет назад

    Woah... bryan you blew my mind!!! The square() on extension int is so cool!! But my question is, is there a reason why you did it on extension, instead of having function with arguments and returning square value??

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      Well, with extension you can call it from anywhere in your project and its easy to use. Functions are quite clunky. Also, the extension makes for an excellent example of how to implement a simple Unit Test.

    • @minchaejeong5010
      @minchaejeong5010 7 лет назад

      I love you bryan

  • @Mr_Jai_Kalra
    @Mr_Jai_Kalra 5 лет назад

    superb

  • @anilsk8561
    @anilsk8561 6 лет назад

    can you plz put some more content on TDD. thank you very much awesome video.

  • @xiandongwang869
    @xiandongwang869 7 лет назад

    how often do you update the instagram class?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      I'm trying to update the course with at least one lesson a day. Apologies for not uploading a lesson yesterday. There will be two lessons uploaded today, episode 16 should already be available. Again, sorry for the wait.

  • @sindhuvannela4407
    @sindhuvannela4407 7 лет назад

    Awesome tutorial...Please explain about Automated UI testing in xcode objective-c

  • @talhaghaffar5742
    @talhaghaffar5742 4 года назад

    which language are you using?

  • @pkasetti
    @pkasetti 7 лет назад

    Is there an iOS Objective-C channel which is as good as this one?

  • @abhishekrajankar9818
    @abhishekrajankar9818 5 лет назад

    Please one video on UI testing

  • @shivam1427
    @shivam1427 4 года назад

    Does the application needs to be built for the unit test to run? OR it’s just like calling functions in our code with some predefined data?

  • @jonathanmartins3816
    @jonathanmartins3816 6 лет назад

    This may seem a stupid question, and I apologize in advance for it, but I'll ask anyway:
    In your square function you used "3" for testing the square value, but let's say one uses "2" for testing; the result must be "4". But, if someone modifies the square function and "by mistake" changes the "self * self" to "self + self", if the testing value is "2" the result will still be "4". How does it assert that my function is right?

  • @Noname98283
    @Noname98283 7 лет назад

    Will the tutorial use storyboard for design or all through code

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      All the tutorials I produce use the simple code approach. Once you get the hang of it, you'll find it to be quite enjoyable.

    • @KyNguyen-sx6ju
      @KyNguyen-sx6ju 7 лет назад

      I started use UI programmatically after your RUclips seri. It's a wonderful change in my iOS development. Thanks Brian.

  • @7848-n6z
    @7848-n6z 7 лет назад

    Thank you for the video, is great and it help a lot =)

  • @V3ritas1989
    @V3ritas1989 6 лет назад

    sooo, in this case you compare the result of your square function to a build in square function. What do you do when you have a more complex function to test? recreate the complex function in your test script and compare it against the one writen in the project? I am not really sure I can follow what you do here. Or would you manually calculate with fixed input value and then hard code the result value while comparing it against the function when given this specific input value?

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад

      I'm not sure if you watched the entire video, but at the end we test a complex function that's in our project that prints out the timeAgoString. You simply create an instance of your objects and test the function calls with some inputs and verify the output is what you expect.

  • @zen_prog
    @zen_prog 7 лет назад

    Thanks Brian for all the amazing tuts.
    what should one unit test in a typical MVC iOS app, what parts should be covered by unit tests other than model layer and business logic?

  • @naveensoni6227
    @naveensoni6227 7 лет назад

    Awesome tutorial!!! I want to learn more about Unit testing. How can we use it for TDD approach? Recently I faced this in an interview, I got selected but still not feeling comfortable regarding TDD. Can you give us any tutorial for TDD approach with swift?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад +1

      I have a friend that does testing for work and he's going to be coming out with his own channel so stay tuned.

  • @aleksplats
    @aleksplats 5 лет назад

    Thanks Brian! Do we need to create separate file for each test? Or do we have to create file for group of tests, or file per logical module?

  • @gokul2226
    @gokul2226 Год назад

    All the junior dev's got attacked 2:14

  • @seandougan8593
    @seandougan8593 6 лет назад

    Great vid man well done - only advice, step-by-step is always better, conciseness and simplicity are they keys to teaching skills. The least amount of words and points that say the most make knowledge acquirable for anyone in your medium.

    • @seandougan8593
      @seandougan8593 6 лет назад

      Examples to check out concretely would be anything from Chad Darby - dudes got the simple down

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад

      Cool, chad goes at a much slower pace so it’s easier to understand. I’m not a big fan of preparing and reading from slides personally, I think I’m too lazy to actually do it.

  • @lucien5112
    @lucien5112 3 года назад

    write code to test code? what if you write bad tests?

  • @HekaFOF
    @HekaFOF 6 лет назад

    Here is a video idea for you: Usually it is not hard to make tests. What is hard to determine is WHAT to test with unit testing. Because you don't want to test trivial things like square. What do you think of this idea? :)

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад

      If you're writing tests, a simple rule of thumb is to test every method that is public. This will help you determine what should be exposed and what should be kept private.

  • @Phaeethon
    @Phaeethon 7 лет назад

    Hi Brian, can you make video about XMPP Chat services? At least quick information :)

  • @Asimov16
    @Asimov16 7 лет назад

    What if there is a bug in your unit test code, and do you have to do a unit test to test your unit test code, and then do you have to unit test your unit test ... infinitum or am I missing the point?

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Well there's always potential for bugs so testing isn't going to be 100% bug free most of the time. Furthermore, writing tests also makes you write code thats simple and easy to test. In the long run, it will save you many headaches.

    • @Asimov16
      @Asimov16 7 лет назад

      I've just got a boss who knows how to break things. Not sure how he does it, but he always finds my bugs LOL

  • @vamsikrishna8820
    @vamsikrishna8820 5 лет назад

    How do we create tests for Watch App?

  • @anthonyschwartz1084
    @anthonyschwartz1084 6 лет назад

    I have a question as a Junior Developer: What kind of app should I bring to the app store to utilize as my resume app? How large, complicated, etc. should it be (are the good app examples that employers would like to see)? I have the basics down, the general requirements for a junior position and I have created 'mini' apps that are very simple in nature, but I don't know what I should create, or how since if it is too big I might be wasting my time (in a way 'wasting time' as in not actively working towards getting a complete app to use as a job resume). Any advice would be great :)

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад +1

      I would set a baseline of creating apps using core data and cloud db such as firebase. I create the paid courses on my website to help people land jobs. Go check them out, I’m sure you’ll find them useful like the rest of my students.

    • @anthonyschwartz1084
      @anthonyschwartz1084 6 лет назад

      Thank you for the quick reply! That is great news! Will take a look at your paid courses and will try to create something around core date and/or cloud db. I really appreciate the advice :)

  • @ABC-xc9il
    @ABC-xc9il 6 лет назад

    excuse me, can you help me, i'm having a problem about error domain 9806 and 9807 requires a certificate of trust
    thank you

    • @LetsBuildThatApp
      @LetsBuildThatApp  6 лет назад

      Excellent.

    • @ABC-xc9il
      @ABC-xc9il 6 лет назад

      @@LetsBuildThatApp I have granted permission in info.plist file but failed, do you have any suggestions for me

  • @IqbalSyamil
    @IqbalSyamil 6 лет назад

    thanks
    subbed😁

  • @gamedevsa
    @gamedevsa 4 года назад +1

    Hi there Brian, thanks for the great video, very informative. Just a tiny bit of constructive criticism. The audio compression ration of your voice is set veeeery high:) See if you can tone that setting down a bit - it will make your voice a bit more natural and reduce over-emphasizing of other unwanted noise.
    Again, thanks for the video, I especially like the fact that you use a very real world application!

  • @programthis3805
    @programthis3805 4 года назад

    very cool!

  • @Asyrafcruz
    @Asyrafcruz 3 года назад

    Sean Allen and Brian Basically The professor we dint have in collage

  • @brightfuturebf
    @brightfuturebf 7 лет назад

    Can we have a video on UI Test?

  • @surekhashinde1195
    @surekhashinde1195 5 лет назад

    Hey, can you please tell us how to write user interface testing for google sign in?

    • @xenibyte5898
      @xenibyte5898 5 лет назад

      That sounds like something that would best be suited to an automated testing tool like Selenium IDE which is used for UI testing and is available for Firefox and Chrome.

    • @surekhashinde1195
      @surekhashinde1195 5 лет назад

      Thank you

  • @AlqGo
    @AlqGo 7 лет назад

    Were test-driven development and agile common practices in your previous jobs? If they were, how did you implement tests in a short iterative development cycle?

  • @michaborski7383
    @michaborski7383 7 лет назад

    very profesional, thank you

  • @Noname98283
    @Noname98283 7 лет назад

    Wait. I can find the instagram tutorial anywhere. is it coming or? i trying to learn how to make a profile account with public and private users

    • @Noname98283
      @Noname98283 7 лет назад

      oh you have to pay. that sucks but get your money up i see you.

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Yep, I think you'll enjoy the course if you like learning about iOS development.

  • @KunalKumar-lx9yg
    @KunalKumar-lx9yg 6 лет назад

    Can you make a video for CI/CD using JENKINS,GIT,

  • @suleymanomari2550
    @suleymanomari2550 7 лет назад

    Hey Brian. Nice job. Can you please share Spotify demo and tinder demo as a course I saw it on your device :)
    Testing is a big part in the development and we should focus more on that but We have so much more to learn on iOS and Swift app development e.g. if the app is inactive and goes to the background what kind of stuff can we do at that state etc.. . Can you please make more apps that is the best way to learn. An application where we have different UIViewControllers and other important stuff from Apples framework involved like MapKit etc. would be perfect. Thanks

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 лет назад

      Yeah, unfortunately I'm a one man team here and preparing/recording everything is more than a full time job. We'll see what I can get done on my starbucks espresso coffee drinks.

  • @JohanAlbrectsen
    @JohanAlbrectsen 7 лет назад

    If you are a Qa/test software engineer, is this the work the person would do?