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

Поділитися
Вставка
  • Опубліковано 27 вер 2024

КОМЕНТАРІ • 448

  • @Roberto-oz6et
    @Roberto-oz6et 2 роки тому +295

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

  • @marmont8005
    @marmont8005 Рік тому +15

    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 Рік тому +2

      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 8 місяців тому +5

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

  • @macmcleod1188
    @macmcleod1188 Рік тому +8

    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.

  • @mastershonobi110
    @mastershonobi110 2 роки тому +38

    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 2 роки тому

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

    • @mastershonobi110
      @mastershonobi110 2 роки тому +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 2 роки тому

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

    • @theblindprogrammer
      @theblindprogrammer 2 роки тому +1

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

    • @theblindprogrammer
      @theblindprogrammer 2 роки тому +1

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

  • @Chronozia
    @Chronozia 2 роки тому +14

    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!

  • @JLSXMK8
    @JLSXMK8 2 роки тому +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.

  • @user-zj6iz1rl8d
    @user-zj6iz1rl8d 3 місяці тому +3

    i wish this dude made spring boot videoes would be gold

  • @samueldnc
    @samueldnc 2 роки тому +3

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

  • @greatjobbuddy
    @greatjobbuddy 2 роки тому +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  2 роки тому +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 2 роки тому +1

      @@CodingWithJohn Absolutely. 100%

    • @greatjobbuddy
      @greatjobbuddy 2 роки тому

      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.

  • @gplus46
    @gplus46 2 роки тому

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

  • @kanchankumari2900
    @kanchankumari2900 3 місяці тому

    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

  • @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!

  • @lucasalledi
    @lucasalledi Рік тому +1

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

  • @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❤

  • @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.

  • @nipunlakshank
    @nipunlakshank Рік тому

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

  • @ultimateguru2
    @ultimateguru2 6 місяців тому

    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  6 місяців тому

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

  • @pokitlui
    @pokitlui Місяць тому

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

  • @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)😍

  • @waffle8364
    @waffle8364 11 місяців тому

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

  • @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.

  • @newgentechinfo
    @newgentechinfo 2 місяці тому

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

  • @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!

  • @henryicruise860
    @henryicruise860 2 роки тому

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

  • @Decent138
    @Decent138 Рік тому

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

  • @mrnoname2462
    @mrnoname2462 8 місяців тому

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

  • @clublulu399
    @clublulu399 2 роки тому

    Learning Hamcrest is in my opinion another essential library to have a good understanding of. Hamcrest library makes asserting test cases more flexible & intuitive

  • @micleh
    @micleh 2 роки тому +81

    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 Рік тому +3

      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 Рік тому +2

      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 День тому

      @@albertbokor6643 must be nice

  • @DavidVCastro
    @DavidVCastro 7 місяців тому

    Amazing how much you covered in 21 minutes!

  • @eduonnetcomputer8878
    @eduonnetcomputer8878 Рік тому

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

  • @kakapyksid
    @kakapyksid 11 місяців тому

    whenever you have covered a topic, you have become my go-to guy to learn new things. It would be awesome if you covered mocking frameworks as well like Mockito which are probably unavoidable for a developer.

  • @lathavoggu2639
    @lathavoggu2639 2 роки тому +2

    Hey John, kindly make one session for Intellij ide usage for java and maven plugin nd other which will make code coverage

  • @trexsupreme
    @trexsupreme 2 роки тому

    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 2 роки тому

      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.

  • @olemato9460
    @olemato9460 2 роки тому

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

  • @ajithak.s.5224
    @ajithak.s.5224 2 роки тому +2

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

  • @darsanas6741
    @darsanas6741 Рік тому

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

  • @saravannanponmudi3091
    @saravannanponmudi3091 2 роки тому +3

    Can you do a video about Heap sort and also Time complexities?? Thank you!!!

  • @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 !

  • @socaljusticewarrior558
    @socaljusticewarrior558 2 роки тому

    Exactly what I need at my level. I'm at the point where I can make my own software, but my code is all spaghetti and it takes a while to debug. Now I'm going to get into the habit of testing it early and often.

  • @Wow-uj3uj
    @Wow-uj3uj 8 місяців тому

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

  • @AkshayDubey-fj7zj
    @AkshayDubey-fj7zj Рік тому

    Thanks a lot!. I wish you could create a video on Unit Testing for Spring Boot Application as well in near future

  • @illegalgiant_
    @illegalgiant_ Рік тому

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

  • @oeufleau8543
    @oeufleau8543 2 роки тому

    About time you started using intellij

  • @khanhsb15
    @khanhsb15 2 роки тому

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

  • @askmax2222
    @askmax2222 Рік тому

    thanks this clarified a lot that the textbook wouldn't cover

  • @kemiles
    @kemiles Рік тому

    Appreciate you and this channel ... would love to see you cover mockito!

  • @lauraluo7242
    @lauraluo7242 6 місяців тому

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

  • @brianruiz8262
    @brianruiz8262 2 роки тому +2

    Just want to say these videos are great and such amazing quality. I would definitely pay for a data structures and algorithm course after completing the Java course.

  • @throwtube4195
    @throwtube4195 7 місяців тому

    Hey little John, you’re like a Robin Hood of teaching!

  • @Adam-ou1qp
    @Adam-ou1qp 8 місяців тому +1

    I attended a 3 hour class which taught me about 75% of what you covered. Your video took 15 minutes...

  • @bandanaboii3136
    @bandanaboii3136 2 роки тому

    This guy knows everything about java 🤯

  • @greatmentors391
    @greatmentors391 Рік тому

    Master of coding 🙌 👏

  • @brenodelgado1128
    @brenodelgado1128 2 роки тому

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

  • @pablop46
    @pablop46 5 місяців тому

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

  • @tarikuasfaw6405
    @tarikuasfaw6405 2 роки тому

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

  • @sunruiheng4255
    @sunruiheng4255 Рік тому

    Awesome overview and introduction to JUnit, thanks!

  • @MY-rl6pv
    @MY-rl6pv 6 місяців тому

    I wish you had a full spring boot tutorial course

  • @nyizeya99
    @nyizeya99 2 роки тому +1

    Your contents are really helping

  • @TomAinsworth94
    @TomAinsworth94 Рік тому

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

  • @iamhassell
    @iamhassell 2 роки тому

    Great intro to unit testing John, awesome! Thanks!

  • @saiashok28
    @saiashok28 8 місяців тому

    Really good teaching. Thanks for sharing this video.

  • @theinthanhlan3582
    @theinthanhlan3582 2 роки тому

    I was so great ful for born in this era.

  • @shaharts8333
    @shaharts8333 6 місяців тому

    Good starter video for unit testing

  • @melbali7828
    @melbali7828 2 роки тому

    John you are the best of the best. Keep it up and would like to see some Spring boot tutorials. Many Thanks

  • @bipulthapa7961
    @bipulthapa7961 2 роки тому

    Please make a video on Design Patterns John!!

  • @dev_project2012
    @dev_project2012 9 місяців тому

    very good explanation , I will use more and more unit test

  • @AbhishekJaiswal-p1u
    @AbhishekJaiswal-p1u Рік тому

    Hi John, you have not written test for the input number greater than 100 which should return invalid value but in the above code it would return an 'A'

  • @mateovansweevelt5257
    @mateovansweevelt5257 2 роки тому +4

    Hell yea IntelliJ

  • @umiskan5819
    @umiskan5819 Рік тому

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

  • @sirfranciscanadianbacon1468
    @sirfranciscanadianbacon1468 2 роки тому

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

  • @mahodaadikari4116
    @mahodaadikari4116 2 роки тому

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

  • @Chime2023
    @Chime2023 Рік тому

    Thanks for your video. I almost see all your videos. So Could you make more videos like the tools, Maven, or Git, or deploy projects into AWS. Thank you so much.

  • @adeibathedon4247
    @adeibathedon4247 2 роки тому +1

    15:00-16:00 wait how would 80 return a b ? When it is suppose to return a C when you set the condition to c< 81 so how would it be b?

  • @VainDoggy
    @VainDoggy 2 роки тому

    Thank you Lex Luthor of Java language ❤️

  • @patricksolomon1923
    @patricksolomon1923 Рік тому

    John, this video was excellent

  • @bbaekkhyyunne_4750
    @bbaekkhyyunne_4750 8 місяців тому

    very clear with thinking procedures

  • @mohamed-alimessedi3
    @mohamed-alimessedi3 Рік тому

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

  • @K4ziq
    @K4ziq 2 роки тому +1

    Hey John!
    Thanks for your hard work! You do great job with this short explanatory videos! Create one with lambda expression please! :)

  • @regatonic
    @regatonic Рік тому

    That was excellent, love your tutorials!

  • @jaaeamor7901
    @jaaeamor7901 2 роки тому

    Awesome video! Thanks for posting!

  • @simonandris4730
    @simonandris4730 9 місяців тому

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

  • @prashanthdp9501
    @prashanthdp9501 Рік тому

    Very organised and very well explained, Thank you!

  • @LthiagoR
    @LthiagoR 2 роки тому

    Amazing!, I'm expecting the video about lambdas, pleaase!

  • @ibrahimadiallo9427
    @ibrahimadiallo9427 2 роки тому

    Hey brother, your explanation is good! keep it

  • @phil7121
    @phil7121 2 роки тому

    there's nothing QA loves more than a dev that makes sure all their unit tests are comprehensive and pass

  • @shukria485
    @shukria485 2 роки тому

    your teaching method is good. can you do Selenium tutorial please

  • @VANTYCSolutions
    @VANTYCSolutions 9 місяців тому

    Wow great video, is there a second part explaining mockito?

  • @cquickstad
    @cquickstad 2 роки тому +2

    TDD. Write the test 1st!

  • @BekTesfa
    @BekTesfa 2 роки тому

    Great 👍🏽 introduction. Can you do advanced unit testing that involves configuration of the test class itself and adding mock beans etc before writing the actual unit tests? Thanks 🙏🏽

  • @savesheikhjarrah1480
    @savesheikhjarrah1480 9 місяців тому

    Clear and concise. ❤️☺️

  • @sanjeetkhare6589
    @sanjeetkhare6589 Рік тому

    thanks John, can you make videos of Junit with mocktio or any mocking framework

  • @christopherwilson8700
    @christopherwilson8700 2 роки тому

    I'm loving your channel! I'm a teacher, and we do a lot of writing in the main method (at least at the beginning of the year. How would I test a certain output of the main method. And how can I test to make sure they used a print vs printf vs println in their code?

  • @HR-pz7ts
    @HR-pz7ts 8 місяців тому

    Amazing as always John!

  • @okorougochukwusamuel9962
    @okorougochukwusamuel9962 2 роки тому

    Hey john kudo 👉 can you make a video on regular expression and lamda.

  • @rollingdice
    @rollingdice 2 роки тому

    thanks John, I learned some new info from this lesson

  • @vinaypawde9894
    @vinaypawde9894 2 роки тому +1

    Hi John.love your videos..you explain both concepts and code very clearly..could you please do a video around stack/queues and bfs/dfs algos? Thanks a lot :)

  • @ВиталийКомлев-р8б
    @ВиталийКомлев-р8б 2 роки тому

    John! Thanks a lot!!!!
    Your video was super duper helpful!
    Really simple and clear for a novice!!!
    Like and subscription!

  • @Sandeepkumar-kk9nk
    @Sandeepkumar-kk9nk Рік тому

    What about the case :- where inside if and else block we don't have return statement and we are doing some operations.
    How to test those scenarios.

  • @asfnobambu
    @asfnobambu Рік тому

    Great! But I was looking for the @Before thing...