Java Unit Testing with JUnit - Tutorial - How to Create And Use Unit Tests

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025

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

  • @Roberto-oz6et
    @Roberto-oz6et 3 года назад +320

    Your channel is pure GOLD! I'm learning more in a few minutes than an whole semester of classes.

  • @marmont8005
    @marmont8005 Год назад +45

    Today, I crashed production because I didn't review and test my code. This was a valuable lesson for me. A colleague with more experience showed me how I could have detected this error through unit testing. We wrote 8 test cases within 20 minutes that could have assessed the functionality of my changes, and I would have noticed the bug. I am glad that we have an open culture for acknowledging errors, and that I was 'allowed' to make this mistake.

    • @marmont8005
      @marmont8005 Год назад +5

      I didn't realize how I had caused this error until we received emails from the company. In a mapper method, I used .filter(Objects::isNull) in a stream filter instead of .filter(Objects::nonNull). This led to the occurrence of the error on 6000 devices. It dawned on me that a slight oversight can impact hundreds to thousands of people. From now on, I will be more conscientious and refrain from putting my code into production until I am 100% sure that it performs its intended function.

    • @JoeyCodes
      @JoeyCodes Год назад +15

      How are ya'll getting jobs out here not knowing how to test your code ;-;

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

      @@JoeyCodes Someone's so toxic and that can't find a job or he got the toxic working environment that he deserves!! Have fun staying in Limbo!! ^^ I don't know why you got a heart by the creator but surely you don't deserve it! None likes you!

  • @tejumania
    @tejumania 2 года назад +77

    Honestly there's no better refresher course on java unit testing than this. Short, precise, keeps your gears turning and leaves you wanting to know more.
    Thank you so much John.

  • @macmcleod1188
    @macmcleod1188 2 года назад +12

    These are all wonderful. I'm a retired Java 6 programmer writing
    Minecraft mods in Java 8, 16, and 17. Your videos are clear and concise! They help me a lot.

  • @micleh
    @micleh 3 года назад +86

    I enjoyed the topic of the video, since unit tests are not necessarily what you have to do at school (and it's not in the curriculum).
    What I also liked was you switching to IntelliJ. I've been experimenting with my students, and we tested 3 different IDEs. They said that they felt most comfortable with IntelliJ and also appreciated the helpful tips that guided them towards fixing errors.
    I'd also like to give you props for the way you present the topics, among them being voice, intonation, gestures and pace.

    • @noobster9212
      @noobster9212 Год назад +4

      Truth to be told, curriculum for computer science in most university is outdated. Most lecturers stopped learning new things whereas the cs world is evolving every second.

    • @ngndnd
      @ngndnd Год назад +3

      im taking a junit class rn and its a complete joke of a class.

    • @albertbokor6643
      @albertbokor6643 Год назад +2

      We actually have a course that goes all in on these features. It feels a bit awkward to do this much stuff for a conceptually small assignemt project but still something practically useful.

    • @gabrielv.4358
      @gabrielv.4358 Год назад

      so true. intellij is the better of them all, and its free

    • @impanthering
      @impanthering 3 месяца назад

      @@albertbokor6643 must be nice

  • @muhammadhassaanbasil8599
    @muhammadhassaanbasil8599 Год назад +6

    Concise, Crisp & To-the-point. Short videos, really time saving. Great work John.

  • @Hurosaki_
    @Hurosaki_ 9 месяцев назад +2

    John, i almost said that this was the most easy topic i learned in java, but when i read other comments, i realized its because your teaching method is simply great. I’m glad i found you!

  • @Chronozia
    @Chronozia 3 года назад +16

    Hey John! I took a course in the fundamentals of computer science last year where our professor mentioned the importance of unit testing and made us all write our own ones without really explaining the reason why or showing how to properly do it. This video really cleared that up for me. Thank you so much!

  • @olillin
    @olillin 2 года назад +15

    I've been trying to learn unit testing for ages and this made everything so much clearer!

  • @raghavanaliassaravananm1546
    @raghavanaliassaravananm1546 3 года назад +18

    Thanks and kudos for the Coverage aspect in Intellij IDEA.

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

    "run our test with coverage" was a requirement for project...Its clearer now. That was a treat. Great video

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

    Thanks!

  • @mastershonobi110
    @mastershonobi110 3 года назад +41

    Very noice!!! As a “beginner” learning on my own these lectures are important lessons. Great Intro exposure to thinking about writing code holistically. Ty. 🙌🏿🙏🏾

    • @mohamedibrahim-qm1cr
      @mohamedibrahim-qm1cr 3 года назад

      we should be friends lol i'm also just started Java! maybe CodingMates?

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

      @@mohamedibrahim-qm1cr where are you in your journey? Are you taking a course? With who? Asking for potential friend. Lol

    • @mohamedibrahim-qm1cr
      @mohamedibrahim-qm1cr 3 года назад

      @@mastershonobi110 just in java for a week now, I'm in a bootcamp plus resource from Plural Sight.

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

      Yes, John's instructions are clear and to the point.

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

      @@mohamedibrahim-qm1cr Which level are you in? Did you reach objects and inheritance?

  • @samueldnc
    @samueldnc 3 года назад +3

    You're brilliant! I'm a senior Java developer but I don't have these didactics and ease to explain/teach. Awesome job

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

    This is the best beginner friendly unit testing tutorial I've found so far

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

    Hands down the best Java channel on YT. I love you John. You just very clearly explained to my dumb brain what the rest of the web really struggled to achieve. Thank you!

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

    I have been watching since a year. Your videos are very simple to understand. Thank you.

  • @gabrielv.4358
    @gabrielv.4358 Год назад

    That is insanely complicated, wow! So cool!

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

    underrated java youtuber, man deserve more views, thanks for the tutorial

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

    I need to give John some major KUDOS. I actually followed the link to his course and now, after like 10% in, I've learned at least 4 or 5 new things that are going to make my life so much easier. Thanks buddy for making these videos and adding a course. Ternary alone is going to save me so much time. A+++

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

      Awesome, thanks! I just added the ternary lesson earlier this week, glad it's helping! I'll be continuing to add new lessons as I'm able, and anyone who has the course already will of course have access to new lessons that are added as well, forever.
      Also with your permission, if you're ok with it, I might also use your very kind words as a testimonial!

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

      @@CodingWithJohn Absolutely. 100%

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

      Sent you an email.

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

    Hit the like, if you have been watching many tutorials and finally, you get the proper context with clear explanations.

  • @kanchankumari2900
    @kanchankumari2900 6 месяцев назад

    Run our test with coverage, John all the expected points you explained in a very simple way , Thanks for your hard work nd keep on doing such a great real time videos

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

    Thank you very much for the video! The teaching and English are perfect for people who do not speak English as a native language.

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

    A video on lambdas expressions would be so awesome, especially when the concept is partnered with runnable class instances. These together are the only way I know in java to make a responsive GUI application.

  • @DC-sp4sk
    @DC-sp4sk 2 года назад

    Best video ever on JUnit by a long shot. Would really love to see more advanced videos on this topic!

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

    Had an assignmen to perform unit testing in Java usign the Junit . Was recommended to watch this video of yours . Your doing a great job ceating content for beginners like me Sir John . Had to subscribe ! Keep up the good and humble work !😇

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

      Awesome, I'm glad it helped! And thankful to whomever recommended it!

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

    As a Java developer, this channel has been very helpful to me in every way.. Thanks to you.

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

    going through your classes while taking part in a bootcamp. really appreciate your help!

  • @user-zj6iz1rl8d
    @user-zj6iz1rl8d 7 месяцев назад +4

    i wish this dude made spring boot videoes would be gold

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

    Thank you for this video. It's clear that this video is just a summary of what unit tests are just like you said. However, only your video was able to really make me understand what unit testing in Java is about.

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

    I'm really thankful to you. I'm currently in the process of studying. And I researched it because my doctor didn't talk about it and I found a similarity between it and the Java language, but it's not a regular Java, it's a test for Java. Thank you. I really understand. And of course I'm proud of myself because I researched who you might laugh at. But that's true. Thank you again❤

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

    This video makes the JUnit test case more easily to implement. Thanks. 🎉

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

    Been exposed to introduction of JUnit today, lucky to have this lesson!

  • @Wow-uj3uj
    @Wow-uj3uj 11 месяцев назад

    This video has made me subscribe. So well spoken and well communicated I had no choice! Thank you for this very informative video

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

    i have not understands this topic in my class but now i am perfect with this topic.... Thank you professor

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

    Every time i look up something on youtube regarding java, and I see johns video available on that topic, what a sigh of relief, hushhhh.! 😅

    • @CodingWithJohn
      @CodingWithJohn  10 месяцев назад +1

      Let me know if there's something crucial I haven't covered yet!

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

    This is an awesome tutorial on how to write JUnit Tests. You explained this so well for a slow learner like me. Thanks for the help!

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

    THIS IS AMAZING! I loved how you provided context and explained everything so clearly!!

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

    No ADs is the silver lining to this channel. 👌

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

    Hi John, thanks for the video. I have to write my own unit tests for a project assignment, but have never done or got properly shown how to. This video cleared all my questions.

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

    Thanks a lot John. I started loving Java after watching your videos! This topic was so interesting.

  • @backtashmohammadi2231
    @backtashmohammadi2231 3 месяца назад

    Every video of yours that I watched, I understood very well. You explain very good. 👍🏻 THANK YOU

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

    now 2:23 am, but I'm sitting and watching you.
    It's so cool. Firstly I'm learning Java, secondly I'm improving my English (at least listening)😍

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

    Thanks for your video sincerely. Every time I learn new things from you.

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

    John your videos are great, clear concise and informative.

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

    Long time programmer but never wrote a single unit test. Its this thing i know i should do, but I seriously never have time for. This video is a actually a great example, ur unit tests tend to use as much or even more lines of code than the original. In the real word the next deadline is always yesterday…

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

    Your videos are GOD SENT! As a person that just started their career as a Java Engineer, I thank you. Keep up the good work.

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

      Keep at it, Java is really nice language.

    • @shukria485
      @shukria485 2 года назад +1

      Did you learn byyourself? I'm on that journey

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

      @@shukria485 Yes, I am self taught. Java is not that difficult language to learn if you spend the time to learn it, if you have any questions about Java, let me know, I will help you if I can. Good luck.

    • @shukria485
      @shukria485 2 года назад +1

      @@theblindprogrammer that's awesome thank you so much.

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

    Thanks for this video!
    I recently joined my first hackathon and I was looking forward to using unit testing in Java for the first time, you explained it very well and it was easy to understand. Nice work :)

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

    I've always been scared of Testing, thanks to this video, I feel quite comfortable with it now.

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

    needed a refresher as i apply to sdet jobs. excellent clear stuff. thanks.

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

    Wow I pretty much appreciate you John I am so happy to get your channel

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

    Another great video John!
    Looking forward to the jvm memory management video; if possible please give it a shot ...

  • @newgentechinfo
    @newgentechinfo 6 месяцев назад

    This video really helpful for my next task.Thank you so much John.

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

    You are great John ! I really enjoy your videos, they are so practical but with a lot of useful information and knowledge. You do that complex topic looks really easy and funny. Keep with this awesome work. Thank you !

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

    Wow! Thank you so much! Your video is really helpful and engaging! Keep it up,pal!

  • @oleksiil.9892
    @oleksiil.9892 2 года назад +1

    Very cool stuff for a java beginner like myself )) thank you!

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

    Awesome overview and introduction to JUnit, thanks!

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

    Your contents are really helping

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

    Master of coding 🙌 👏

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

    this man should be canonized. your videos are SO helpful, thank you for your work

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

    Crystal clear explanation, thank you!!

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

    Great intro to unit testing John, awesome! Thanks!

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

    Thank you John! For such high quality tutorial.

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

    Hey John
    Thank you so much for this video , you were just explain the basic unit testing in a simple way.
    This is a great video for beginners.👍

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

    I'll pass a string for ut algos to pick up John. He deserves million subs.

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

    Awesome vid John, thanks for going into so much detail in an actual use case!

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

    I actually liked the video even i did not started to watch it yet. I wanted this video to come so much. Thank you

  • @HR-pz7ts
    @HR-pz7ts Год назад

    Amazing as always John!

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

    Thanks I got to learn how junit test case works , how to create one , what is code coverage and we should try to write test cases which cover most of your coverage , assert types and finally a basic understanding of test case and its importance

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

    Hey John, congrats for your content. It's really clarefull and understood. Thanks from Brazil, let's keep coding.

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

    About time you started using intellij

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

    Hi John , you are the reason who i love the Java. Every video is incredible understandable. Thanks a lot 😎

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

    Thanks John, I understood the basics of JUnit test in Java through your easy to understand examples. 😊

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

    Great explanation! Great work!
    Simple and to the point
    Thank you!

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

    That was excellent, love your tutorials!

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

    It's a wonderful video!! Many thanks John

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

    Thanks for making current and superior Java videos

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

    Hey, first of all, a huge thank you for making these videos! they're great help to me and anyone that is studying and learning java on their own or even in school but need more to understand everything better.
    Also, I wanted to ask if you have any plans about making a video of how to use an API. I do know it's very simple to look it up in the internet, but your videos are very clear and easy to understand so it would definitely help me a ton! thanks in advance:)

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

      I am just curious, what kind of an API are you looking for? Are you looking for RUclips API or Twitter API? If so, let me know I might attempt it showing you how, I am not as good as John (obviously), but I can try.

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

      @@theblindprogrammer I was looking for a more general view of it and overall how it works, I have an idea of the process as I studied it in python a year ago in university and even though I can't remember it very well now, if it's anything like python, it should be pretty simple to get into. I practice java by doing small to medium projects and every time I try to implement something new that I've studied into my project, and I'm feeling API's would be a nice addition!

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

      @@lqrock5438 Yeah, calling APIs in Java is similar to python except in Java, it is a lot more verbose than needed. You can try it with news APIs.

  • @k.k9206
    @k.k9206 2 года назад

    That was awesome john! great explanation! Thank you so much.

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

    thank you, i was able to create and test individual test cases with this video.

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

    That was so well described. Very very helpful. Your videos are also produced very well.

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

    That was very informative . Thanks for sharing your knowledge with us

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

    The one testing framework I've ever loved and enjoyed was RSpec for Ruby or Rails. Extremely easy to setup, read and write tests.

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

    Amazing how much you covered in 21 minutes!

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

    Love your content! Keep on, John!

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

    This is so nice and wonderful way of teaching

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

    Beautifully explained! Thank you very much!

  • @mohamed-alimessedi3
    @mohamed-alimessedi3 2 года назад

    Thank you very much for sharing this in such a clear way.

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

    Really good teaching. Thanks for sharing this video.

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

    It was a good thing, thank you

  • @ajithak.s.5224
    @ajithak.s.5224 3 года назад +2

    Simple and precise illustration. Thank you John. Probably including parametrized junits supported in Junit5 would be better.

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

    Clear and concise. ❤️☺️

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

    very nicely explained in short time and covered very good scenarios!! Thanks for your efforts :)

  • @pablop46
    @pablop46 9 месяцев назад

    Nice work! Really informative video and easy to follow along on

  • @adityakeshan8176
    @adityakeshan8176 2 года назад +1

    Gold every minute of it

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

    U are amazing bro. For one video, I understand Unit testing.

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

    John, this video was excellent

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

    Thank you John, much appreciated!❤

  • @ndk8111
    @ndk8111 2 года назад +1

    Thanks John.
    Finished your lecture then went to try to implement a few of the junit5 test methods for the very first time. Your explanation was very good. One thing I wished you touched was how to resolve dependencies needed to run junit5. I grabbed one of the dependencies in mvn repository Jupiter-engine and that seemed sufficed to resolve my missing assertTrue(). These small things very briefly but ought to be covered In your demos I think.

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

    Thanks John. Another crystal clear explanation. Straight to the point 👌 💯