Это видео недоступно.
Сожалеем об этом.

What is Unit Testing? Why YOU Should Learn It + Easy to Understand Examples

Поделиться
HTML-код
  • Опубликовано: 3 ноя 2018
  • If you haven't come across unit testing and wondering what it's all about then take some time and watch this video. It's a quick primer on unit testing with some super simple examples to illustrate some basics. Let me know if you have any questions in the comments!
    ** GitHub Link for Code Example **
    github.com/and...
    ** Coaching **
    Want to work with me personally to get your software development career started? If you consider yourself an action-taker who is fully committed to putting in the work then book your free Career Strategy Session with me by going to andysterkowitz....
    To join my facebook group go to: andysterkowitz...

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

  • @AndySterkowitz
    @AndySterkowitz  5 лет назад +136

    Does this give you a basic idea about unit testing? Is there anything unclear or that could have been further explained?

    • @cryptochef70
      @cryptochef70 5 лет назад +1

      Hey Andy! Could you set more free time? There aren't any available dates to talk to you D:
      If not, could I take your e-mail? cryptodecuisine@gmail.com

    • @mohammadakbar32
      @mohammadakbar32 5 лет назад +1

      Hi Andy, first of all i'm really sorry for my first comment at your channel where i wrote "Andrew" instead of "Andy"!, it is great information about testing, i just heard about Unit testing but never got this much information! Thanks Andy

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

      Andy Sterkowitz No times are available to schedule a career strategy advice call with you.

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

      Excellent refresher on unit testing! One small addenum to your video: When you created the should_create_tesla_make(), I think you should've mentioned that you wrote the test to explicitly test *only* the "Make" parameter of the CreateTesla() method, although you did mention that this method will require testing at least 2 parameters (Make and Model). Appreciate that you went the extra step by creating & running the should_create_tesla_model() test method as well! Thanks!

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

      Thank you for this video..
      It helped me understand what is unit testing

  • @alimfuzzy
    @alimfuzzy 5 лет назад +67

    Our devs have written in big letters on the board that reads "Write your tests first". Before they write the code they develop the test. It helps them ensure what they are building is well thought out.

  • @jt659
    @jt659 5 лет назад +130

    Apparently "Oh yeah, I test the shit outta units!" isn't a valid interview response.

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

      Haha #winning

    • @adamgdev
      @adamgdev 3 года назад +6

      I have not been in the hiring position...but if I was, I like that response and it would make me laugh. There should be more laughing in the interview process imo

    • @tjobrien7518
      @tjobrien7518 3 года назад +6

      response = "Oh yeah, I test the shit outta units!";
      if (response != valid) {
      findNewCompany = true;
      }

    • @Mmmkay..
      @Mmmkay.. 2 года назад

      😂😂😂

  • @mandor955
    @mandor955 5 лет назад +24

    This is a really helpful video! I've always heard this topic but never really known how to approach it but this is a really friendly approach to unit testing since it seems like a monster when thinking about it initially.

  • @hmajor023
    @hmajor023 5 лет назад +27

    This video was very helpful Andy I heard of Unit testing before but never understood what if was for and how it works. Now I have a better understanding of both. If you have references on how to learn more about Unit testing you would like to share I would appreciate it. Thank again.

  • @hovarda0655
    @hovarda0655 3 года назад +1

    Like Andy said my organization does not do this so when i had an interview with another company, they asked me if i write unit tests, I said no, and they looked at me like I was some alien. So now I am here, thanks for the video!

  • @SuperPoower
    @SuperPoower 5 лет назад +17

    This video came at such a good time!! Im building an API and want it to do some Unit testing, but i was kinda lost. Thanks Andy!

    • @AndySterkowitz
      @AndySterkowitz  5 лет назад +4

      Awesome! What language are you writing it in?

    • @SuperPoower
      @SuperPoower 5 лет назад +4

      @@AndySterkowitz im writing it in C Sharp. So it was a perfect example you gave.

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

    Thank you, Andy. You are a great teacher with much enthusiasm and passion for your work!

  • @ChaosArtist
    @ChaosArtist 3 года назад +5

    Very helpful. I recently started looking into unit testing again and I was looking for some simple breakdowns of how unit tests work.

  • @MrSpacelyy12
    @MrSpacelyy12 5 лет назад +70

    Man it is so hard to self educate yourself lol glad to have RUclips lol

  • @borischen4031
    @borischen4031 4 года назад +4

    Great video on Unit Testing, we briefly covered it in our boot camp. But simple, easy-to-understand examples!

  • @baatar
    @baatar 4 года назад +6

    I really like that you're providing coaching service, this is the first time I've seen anybody from RUclips offer that, very innovative of you :)

  • @yassineyounes3479
    @yassineyounes3479 5 лет назад +2

    I went into your channel and searched for the follow up videos but no luck!
    Thanks for the great video and I hope you cover the rest in the future!

  • @meh.7539
    @meh.7539 2 года назад +6

    Unit Testing == Testing a single 'unit' of your code. That unit is as small as you define. Most of the time I've seen it down to the individual method or function level but it could be as small as a single statement if you really wanted to put the work into it.

  • @Ryan-nq3qp
    @Ryan-nq3qp 3 года назад +4

    I think it would've been helpful for learners to hear that the use of interfaces does wonders for unit testing. Which would naturally lead to methods of those injected interfaces to then be mocked. Etc.

  • @The_Nova_Glow
    @The_Nova_Glow 5 лет назад +6

    You explain stuff SO WELL! I just wish the example code was in JavaScript or PHP

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

      He didnt teach us any syntax, so it doesnt matter. Thats because the syntax will change depending on the testing framework

  • @Malibukenn
    @Malibukenn 5 лет назад +11

    I don’t understand why most RUclipsrs(Andy included) don’t talk more about the importance of KNOWING algorithms AND time complexity. Because when you go on an interview in 2019 or beyond, companies don’t care about your projects or your github. They know at this point that stuff can be fabricated. Taking a code test or doing the White board interview is more important than any of this gibberish.

    • @timtruett5184
      @timtruett5184 3 месяца назад +2

      I had a job interview where I was asked two questions. First, in the Chomsky hierarchy of languages, what type of language is xml? Second, using the big-O notation, what is the runtime complexity of a dictionary abstract data type?
      Both questions related to what they did at that company. I thought the questions were kind of basic, and I answered them.
      I got the job, but I later regretted accepting it because of how I was treated by the Indians of the company. It was the last software job I ever had.

    • @kgovind2171
      @kgovind2171 Месяц назад

      They are just aholes . Continue in this field sir​@@timtruett5184

  • @86_kazuki35
    @86_kazuki35 4 года назад +2

    Hey Andy! Thank you for hitting the topic. It helps with a better understanding how unit testing works and from the looks of your github. I was able to kind of understand how to setup the testing but not fully.

  • @kenfrancis4850
    @kenfrancis4850 5 лет назад +2

    Great video, I would love to see deeper technical stuff from you. Thanks

  • @corritaylor82
    @corritaylor82 5 лет назад +5

    Question, I've been researching employment in my area and I've come to find that unit testing knowledge is needed. The 6 major of Unit testing involve Mocha, Chai, JSHint/JSLint, Cypress, Jasmine and JSUnit. I'm leaning more towards Cypress because I code with Node, but also am learning Angular and React down the line. Out of the 6 I listed, which do you use and why?

  • @bryanstark324
    @bryanstark324 5 лет назад +5

    Wow when I watched this I thought how the hell would I do that for the thousands of lines of code I have? I guess what this is was a demonstration of just verifying that the correct output is produced by the input. Is that basically what "unit testing" is?

    • @AndySterkowitz
      @AndySterkowitz  5 лет назад +2

      The key to unit testing is that your code is modularized. Testing thousands of lines of code is very difficult if not impossible. However if you had modularized your code to the point where you can test each module, now you can start to see how it can be possible.

  • @ZealousSwede
    @ZealousSwede 2 года назад +2

    Maturing as a developer is growing to love tests ❤

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

    I am taking a university degree they just threw material about testing .Guess what I have been stuck for days ,this video cleared a lot for me ..I kept on testing a function that connects to a database and ran into tonnes of errors

  • @fastersixth
    @fastersixth 3 года назад +2

    Trying to learn tests and this was amazing! Thank you! Great video!

  • @joseph181516
    @joseph181516 7 месяцев назад

    Bro, awesome video! I wish you can add captions to non-native english speakers like me. Pretty useful!!!

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

    Memory Testing. To test individual class file with memory variable to make sure it can run by itself without fail. Validity of test data to make sure it can function within the code itself.

  • @jstnflnt
    @jstnflnt 2 месяца назад

    Thanks for the beginner-friendly explanation

  • @THExRISER
    @THExRISER 3 года назад +8

    Finally a video that explains unit tests like I'm five.

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

    I needed to have an idea about 2 subjects, Angular and Unite Testing. And you talked about Unit Testing IN your Angular video. WHAT ARE THE CHANCES?! Thank you.

  • @johnathanbeal9785
    @johnathanbeal9785 5 лет назад +5

    Great Video! I do have a question: What is the difference between a Mock, a Stub and a Fake?

    • @AndySterkowitz
      @AndySterkowitz  5 лет назад +2

      I would explain in this comment but this post actually does a terrific job of explaining it in detail: blog.pragmatists.com/test-doubles-fakes-mocks-and-stubs-1a7491dfa3da

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

    i love the background view, amazing

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

    i love your apartment, makes me miss chi

  • @BatteryProductions
    @BatteryProductions 5 лет назад +1

    you highly encourage me to do some research, how do you think i got to your video?

  • @TheCameltotem
    @TheCameltotem Год назад +1

    I've been a dev for 5 years soon and I still don't see why people get so hyped on unit tests.
    First of it shouldn't even be called test. It should be called business logic validation, because that's what the hell we are doing.
    Second. Why do these "tests" even exist? It's only there to validate the business logic and if you know the business logic and expected output then why would you need to test for it.
    It's expensive to write and maintain and it don't test user flows. It should be used in some cases but not all.

  • @RY-it6lm
    @RY-it6lm 4 года назад

    Great explanation. Short and sweet.

  • @cu806
    @cu806 5 лет назад +1

    Yep. Ty

  • @AshishGupta-xw9yh
    @AshishGupta-xw9yh 2 года назад

    Great Description Andy!!

  • @erices3307
    @erices3307 4 года назад +2

    Better late than never ;)
    I'm about to start my thesis and I picked this subject based on my boss's recommendation and found it to be very interesting. I was confused at first, nontheless, about how it worked, but this video was great for setting me on track. Thank you!

  • @Furiac.
    @Furiac. 5 месяцев назад

    clear, thanks.

  • @RameenFallschirmjager
    @RameenFallschirmjager 5 лет назад +1

    enthusiasm shines from your face!

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

      I love testing 😊

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

      @@AndySterkowitz tell me this when cops stopped you when you was driving under influence after a party! just kidding I know developers all enjoy responsibly!

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

    Bro, really nice video. Cheers from Brazil.

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

    Solid quick video. Thanks!

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

    Another very helpful video. Thanks!

  • @ifstatementifstatement2704
    @ifstatementifstatement2704 2 года назад +2

    I recently have had to use unit testing in a new role. Prior to that I had never used it and everything I programmed worked just fine. My personal opinion is that it's a huge waste of time. You want to program something, you program and run it. It crashes, you fix the code until it doesn't crach anymore. End of story. The more I stay in this software engineering role, the more I suspect this industry has invented a lot of additional stuff to delay the delivery of a product and waste the client's time.
    Apparently the purpose of unit testing is to ensure quality standards. Quality to me means the program works and does what the client asked, and does not crash when used. That can be achieved in a more straight forward way and faster without implementing unit testing. But hey, I get paid to do what I love: code. If that means wasting the client's time, let's chuck that up to a business decision.

  • @killagorilla403
    @killagorilla403 5 лет назад +2

    This was great! Thank you!

  • @user-gh6lh6nn7k
    @user-gh6lh6nn7k 11 месяцев назад +1

    why caption is unavailable? 😭

  • @ericnyarko-sampson1947
    @ericnyarko-sampson1947 4 года назад +1

    Yo man, thanks so much for the explanation

  • @akramazad5137
    @akramazad5137 5 лет назад +2

    Hi Sir, can I become like you software developer in 3 years?

  • @zezeandjr4110
    @zezeandjr4110 5 лет назад +1

    In previous lives, I used Test Track Pro by Seapine Technology, that company was acquired by Perforce and the product is now called Helix TCM, but the product was very powerful at the time, are you using similar things in your automated testing?

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

    Thanks for this info!

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

    Thanks for the video! When you said 'do some research on your own', could you provide some good resource?

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

    Highly informative

  • @Dhananjaykumar-ro6zg
    @Dhananjaykumar-ro6zg 3 года назад

    could you please make a video for the xUnit over very simple programming that I can understand. I would really appreciate it.

  • @devens03
    @devens03 8 месяцев назад

    Awesome video!!

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

    thanks

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

    thank you

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

    if i applied this stuff to the android app i've been making for work i feel like i would have to write about 300,000 tests... and the app isn't that complicated. how do you know which units to test or not?

  • @michaelodonovan6989
    @michaelodonovan6989 3 года назад +2

    Great vid, thanks! Can I ask - do you have an opinion on whether it is best to be using proper IDEs if you are doing this depth of work/testing?

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

    why can't you do more tutorials like this please? you probably won't ever answer me but please more videos like this.

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

    Thanks a Million for the Video. Can a self taught, code bootcamp grad be a Freelancer?

  • @peristiloperis7789
    @peristiloperis7789 5 лет назад +2

    Still I can't undertand why unit testing is useful. Is it valid for codes writen by a single person or is it only necssary for a group of programmers?

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

      Both. In an application it can help ensure that changes made to existing code doesn’t break. If you use a continuous integration server you can have all the tests in your project run each time you or someone else commits to a code base. This will help catch so many errors before they bubble up into production bugs.

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

      @@AndySterkowitz, thanks for the answer. But can you make video with a real example or something? Maybe I don't see why this is important(although I know it's important, :-)) because the example is too simple.

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

      @@AndySterkowitz Often is the case that changes don't break existing code but the unit test code.

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

    So unit tests are written when we know the code is working and we don't want it to be changed in future. Am I correct?

  • @Hyperlooper
    @Hyperlooper 5 лет назад +1

    Would the units you are typically testing be more complex than what is shown here? The test itself is more complicated than the unit it is testing in the example.

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

      Definitely. This is meant to be a super simple example. Real life modules will typically have more logic that needs to be tested through each individual test.

  • @emkygsz
    @emkygsz 5 лет назад +1

    Can you add subtitles? It will be perfect!!

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

    Can you do more videos like this please

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

    Thanks for the explain but i still dont get it. If i create a Tesla and within its constructor it uses the const char ptr "Tesla" to name it. Why should i test if its realy named "Tesla" ? I know that this is an easy example to understand but i dont get it. Its maybe the better way instead of put breaks or printf the Variables?

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

    So how do you know what to test? I guess if you have a piece of logic that accepts data coming from different directions? My biggest issue rn is writing code to handle when data is not there.

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

    Shouldnt the object result be instantiated by the CarCreationService class method and not the _teslaCreationService class method?

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

    Great video!!!!

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

    thanks dude!

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

    7:52 is usually during the second half of the day ;)

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

    How can you know if your test is complete and correct? Can you make a test for your test?

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

    Are we testing Te-Z-la or Te-S-la?

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

    What books do you suggest to get muscles in Unit testing?

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

    How and when are all these tests run?

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

    Why should I unit testing when I can debug? I really wanna know the reason why debugging isn't enough

    • @AndySterkowitz
      @AndySterkowitz  11 месяцев назад

      Instead of testing the app manually (running the app and putting it through different test cases) you can write automated tests that do the work for you. This is the simplest way I can explain it.

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

    thanks!

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

    I always remember when he got his first job.
    I was just like " he made it " and here we go I taught myself as well and been working for 5 months
    thanks

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

    Note to any Developers: If your company is NOT implementing any tests in the codebase, please do yourself a favour and QUIT, you deserve so much than said company AND/OR suggest they implement some testing framework, if that fails refer to previous step.
    FYI, I have never been in a company that does NOT use some sort of testing framework whether it be Karma, Cypress, python unittest, Selenium, JEST, etc.

    • @BrieoRobino
      @BrieoRobino 4 года назад +4

      Terrible advice. Plenty of legacy systems don't have test suites and implementing them would take months which would be hard to justify to upper management. Plus as long as the money is good who cares?

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

    Excllence. Never did this, and feel pretty stupid now ha

  • @AjayKumar-fd9mv
    @AjayKumar-fd9mv 4 года назад

    I would like to know response from the people who read this comment ,so If you have some time to spare, please answer my questions.
    1) Have you ever been asked by your supervisor to skip the unit testing code in order to save time and push the code to production ?
    2)Does your codebase contain broken tests from the past which was caused by another developer who did not bother to fix it before committing his changes to repository ?

    • @AjayKumar-fd9mv
      @AjayKumar-fd9mv 3 года назад

      @Alexandria Amoretti Thanks for the reply. just out of curiosity, what technologies do you work on?

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

    What do you think about Head First Python, is it a good book to start learning Python?

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

      The headfirst books are a bit outdated tbh, i would look elsewhere

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

    Thank you for the video.
    I have one question, what if I have no mutch time to test my code?
    Here we are building apps in two three weeks, and I have no time to make tests. Can you suggest me something?

    • @isMeStranger
      @isMeStranger 3 года назад +1

      Maybe first discuss the layout and the basics of your idea like the basic functions, what type each function/method is going to return + basic components of your app before starting to code.
      After that, assign few members of your team to use this info to write the testing code even before writing the app code, while the other members write the app code. This way you will have two parties in your team runnning at the same time, one writing your app, and the other writing the test code.
      I am a CS student and this is just my suggestion. Please do further research. There might be easier ways since this is just an idea that i came up just now.

    • @pedromassango
      @pedromassango 3 года назад +1

      @@isMeStranger Thanks bro. My comment is 2y old so far and I've grown a lot professionally. What you said makes a lot of sense.
      My current approach is to write unit tests at least for the most important features when I don't have too much time

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

      @@pedromassango Hello, thanks for your reply and for providing your current approach, it might be userful experience to know how people are working as programmers/developers as im graduating soon. Its good to see that you are much better at what you do now. Goodluck.

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

    That weird moment when your expected output is 'tesla'
    And actual output is 'system crashed'

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

    Awsome mate I'm here in 2021 I'm really committed in learning about how to host and code my own bot and server I have been trying to understand the language for months on end non stop 😴 I have been using the python progam to help me am I doing the right things

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

    I was just telling some student a about this they didn’t teach them in school

  • @MisterKorihor
    @MisterKorihor 3 года назад +2

    Unit testing has very limited usefulness for most web apps. 95% of the code that you write either interacts with the database or deals with the UI. And you can't unit test those things.

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

    You have a really nice view from your office.

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

    I watched the cloud fly.

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

    I still don't really understand why wouldn't you just print the value and compare it in your brain?

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

      Because you can’t automate that 😊

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

      @@AndySterkowitz It just seems like a big waste of time writing the tests if you're just comparing variables. It does make sense though if you're working in a team and you have tests run whenever someone commits, that can be very useful but then you would have to write new tests for every single new feature you add, right? I don't want this to sound like I'm criticising it, I just don't really understand....

  • @MR-rc4de
    @MR-rc4de 3 года назад

    The sound quality is poor

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

    TeSla! Where did you get TeZZla from?😂

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

    "Tezzla"

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

    Then you gotta test your tests

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

    Unit test is useless. Ideally the unit test code should cover all possible scenarios and thus eliminate bugs. But most unit test code I've seen only uses one or two set of data. So passing these tests only means that the code passed the most basic check. Also there's the tedious job of fixing unit test code once the original methods are changed. This is particularly true in Salesforce development where unit tests have to be verified in deployment.

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

    You look like john frusciante

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

    i hate unit testing. i never do it.

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

    TDD is a thing but it requires a need for quality and it requires trust from the management.
    I can see it for zero interference once deployed projects like Subsea Wellheads but anything other than that it will probably be too expensive.
    Quality that can't be patched it very rare and that reduces TDDs value point.
    It works but it might just be a bit expensive.
    The world now is used to failing commodities. We are in the era of Planned obsceneness. Stuff won't last by design.
    Building something of quality is counter productive in a capitalist society.
    That's just depressing.
    Luv and Peace.

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

    too simple examples.. how to you test methods with no return?

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

    Waste of time, extra work.

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

      Good luck getting a job without knowing this.

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

      @@BrieoRobino Getting a job by memorizing something about unit test from a book and passing job interviews is quite different from actually using unit test in real work.