Spring Boot Testing | Writing JUnit Tests using JUnit and Mockito | Java Techie

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

ความคิดเห็น • 370

  • @fikirwalle843
    @fikirwalle843 4 ปีที่แล้ว +167

    you save my life, because of this i passed interview

    • @lenigaussgauss2428
      @lenigaussgauss2428 3 ปีที่แล้ว +9

      I'm very happy for you guy

    • @deepamuniraju2709
      @deepamuniraju2709 ปีที่แล้ว +2

      Wow 👌

    • @timepass6935
      @timepass6935 ปีที่แล้ว

      You are still alive . After lots of lay offs 😮

    • @Javatechie
      @Javatechie  ปีที่แล้ว +5

      Be positive buddy. Please don't repeat it again

    • @DK-js8cz
      @DK-js8cz 6 หลายเดือนก่อน

      what question they asked bro?

  • @sayan_shee
    @sayan_shee 3 ปีที่แล้ว +66

    Awesome content, pretty straight forward. Some people are complaining about communication. Don't worry about accent/communication as long as your content is good.👍🏻

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว +3

      Thanks Sayari 😊

    • @nikhiljhawar4612
      @nikhiljhawar4612 3 ปีที่แล้ว +1

      @@Javatechie Nice and presized content. I just wanted to know when you're getting user with address="Bangalore", then the user returned is having address as "USA". So, could you please help me understand that.

    • @ajaydarshanala8051
      @ajaydarshanala8051 2 ปีที่แล้ว +3

      @@nikhiljhawar4612 That's a good question. If you see the service method , it has no business logic. as the repository method is mocked here, it really not checking bangalore . It will always give the usa user object, because the method is mocked. In real time, the service method will have business logic to check bangalore, this video helps to understand the concept. @10.34, he used a term "for testing purpose ". Hope this comment helps.

    • @mahadevaswamygn4216
      @mahadevaswamygn4216 ปีที่แล้ว +1

      @@Javatechie Thankyou ,what i learn till now thats only from you.very helpfull for me ,

  • @shretasathe6409
    @shretasathe6409 3 ปีที่แล้ว +11

    Very very helpful. You are a life saver. I was stuck on this issue for so long. And trying your method solved the issue within seconds. Thank you so much!!!

  • @steambassador
    @steambassador 2 ปีที่แล้ว +3

    Before this video i watched many others related to Unit test, and the make it more difficult. After watching your video, i started to implement tests directly on my codes!!! thanks for making it simple to understand.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @suhashari2988
    @suhashari2988 5 ปีที่แล้ว +19

    very helpful. like how you showed what the mock object does using a print statement in service layer.

  • @santoshkamat6132
    @santoshkamat6132 4 ปีที่แล้ว +5

    ❤️ you brother. U have solution to each and every problem. May god bless you for the service you are doing towards the people

  • @sanskardwivedi2375
    @sanskardwivedi2375 4 ปีที่แล้ว +4

    The only video where i learned this concept properly, amazing

  • @anthonyvinay9943
    @anthonyvinay9943 2 ปีที่แล้ว +2

    Simple and Concise. 100% to the point content. Thank you so much for this educational content.

  • @gayathrikota1194
    @gayathrikota1194 5 หลายเดือนก่อน +1

    Best channel ever... Tomorrow I have interview..Revision of topics

  • @kingsroyal1600
    @kingsroyal1600 2 ปีที่แล้ว +1

    The best best best channel 🙏❤really every video awesome, the way he is explaining very easy to understand 🙏🙏thank you so much!!!!!

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks Krish ☺️

  • @Javatechie
    @Javatechie  4 ปีที่แล้ว +3

    Hi Team , don't be confuse in repository.findUserByAddress() , if you observe when(dao.findUserByAddress(any)).thenReturn(Any user object) so irrespective of any address value i will get that user object which i mention in thenReturn , that's what mockito does for use

    • @sivasiva-wn6os
      @sivasiva-wn6os 4 ปีที่แล้ว +1

      In the code coverage it is not covering all the clasess what should I do please help me

  • @divyanshujaiswal6710
    @divyanshujaiswal6710 2 ปีที่แล้ว +1

    Thanks for proper and complete video for API basic testing.

  • @jasper5016
    @jasper5016 3 ปีที่แล้ว +18

    Thanks for covering Mockito. I believe this is Junit 4. Can you please cover more test cases with Junit 5 and with different situations including how to handle exceptions and all?

  • @ramrajendra3240
    @ramrajendra3240 3 ปีที่แล้ว +1

    You just saved my all time n efforts to learn mockito.
    Thanks

  • @sharadsingh2856
    @sharadsingh2856 2 ปีที่แล้ว +1

    Very clear explanation of mockito and junit. Thank you very much.

  • @sunithareddy8813
    @sunithareddy8813 3 ปีที่แล้ว +1

    When I am waching your vedios easy to understand sir 👍Thank you sir

  • @shahjadealam4887
    @shahjadealam4887 2 ปีที่แล้ว +1

    Thank you so much. you made my UT very easy now. very simple and easy way to understand.

  • @alfzapc
    @alfzapc 4 ปีที่แล้ว +11

    Hi, if you having this warning: "no test found with test runner junit 5", you need to import:
    import org.junit.jupiter.api.Test;

    insted of
    import org.junit.Test;
    Btw: Thanks Java Techie

  • @bhushansonaje
    @bhushansonaje 3 ปีที่แล้ว +1

    Very Good Example !! Thanks for all efforts

  • @qaziiffatjabeen
    @qaziiffatjabeen 3 ปีที่แล้ว +2

    Brilliant, precise and to the point video... Thank you Sir...

  • @adishjain2507
    @adishjain2507 3 ปีที่แล้ว +1

    Sir, thanks for explanation in easy to understand language

  • @Artistsonu_743
    @Artistsonu_743 3 ปีที่แล้ว +1

    point to point content, this really helpful for us.

  • @srinivasang1062
    @srinivasang1062 4 ปีที่แล้ว +4

    This saved my time. Thanks a lot! Please work on your communication, You'll surely reach heights.

    • @NeverQuitOk
      @NeverQuitOk 3 ปีที่แล้ว

      what a negative thinker you are. Useless guy thoo

    • @srinivasang1062
      @srinivasang1062 3 ปีที่แล้ว +2

      @@NeverQuitOk That's a constructive criticism. From the bottom of my heart, I'm wishing Java Techie(Basant) a great success. He's & will always be my fav tech TH-camr.

  • @SurajKumar-qb9jb
    @SurajKumar-qb9jb ปีที่แล้ว +1

    Thank you for the videos. Very helpful. Keep doing the good work. :)

  • @muhassinmusthafaa2479
    @muhassinmusthafaa2479 2 ปีที่แล้ว +1

    Very good tutorial..very simple..small request.. some words are difficult to undertstand while u explaining so that some points are missing...try to make it clear...rest is very best..U have done a simple and great job..

  • @shubhamsaurav42
    @shubhamsaurav42 2 ปีที่แล้ว +1

    communication is good as easy to understand and content is also good thanks

  • @veenatiwari8621
    @veenatiwari8621 ปีที่แล้ว +1

    sir , Wanted to say , i watched your most of the video , and i cleared my interview for onsite , thanks to you by heart , really like your way of expressing the topics , thanks a lot sir , your videos helped me alot, feeling like you as god messenger to help me , you are from West bengal or south ?

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Hi Veena i am so glad to know your achievement Keep learning 😃

    • @veenatiwari8621
      @veenatiwari8621 ปีที่แล้ว +1

      @@Javatechie yes sir , now also learning from your videos and implementing the thing in my new project , Thanks a lot sir

  • @mohammedshalibasha2249
    @mohammedshalibasha2249 2 ปีที่แล้ว +1

    thank you so much SIR very nice and clear explanation!

  • @aigulsharip2091
    @aigulsharip2091 3 ปีที่แล้ว +1

    Thank you very much for your videos. I found them very useful.

  • @kirankumarmothukuri8744
    @kirankumarmothukuri8744 3 ปีที่แล้ว +1

    Great Job. easy to understand. I would appreciate if you elaborate more.

  • @mahanthagouda2579
    @mahanthagouda2579 2 ปีที่แล้ว +1

    superb sir , good explanation.

  • @jax40001
    @jax40001 3 ปีที่แล้ว +1

    So helpful. I suggest your video to many of my colleagues

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Thanks buddy 😊

  • @wolfmohit
    @wolfmohit 2 ปีที่แล้ว +1

    No non-sense guy with awesome content!!

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @percymoganedi4959
    @percymoganedi4959 4 ปีที่แล้ว +5

    You always make things easier for me to understand. If I may ask do you have full completed course and other full courses that are related to spring framework

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      Thank you , If you checkout my playlist all the content you can get

  • @vaishali5.r
    @vaishali5.r ปีที่แล้ว

    Hi, thank you for the great video. One question - You did not add when(repo.delete).thenReturn(user). Is it not needed in delete case to make sure actual delete method is not called?

  • @01cybrain
    @01cybrain 4 ปีที่แล้ว +1

    Superb explanation Sir. Many thanks 👍

  • @richarddanladi9802
    @richarddanladi9802 3 ปีที่แล้ว +1

    Very helpful, Thank you for this useful content

  • @adammoe605
    @adammoe605 3 ปีที่แล้ว +3

    Nice Video & explanation! Why the GetUserByAddress method is returning 1 i(searching for Bangalore our mocked DB has USA) ? assertEquals should be (1,0) I am new to this Am I missing something Thanks in advance

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Request you to revise video once again .I could answer your question but u want you to understand it 🤫

    • @adammoe605
      @adammoe605 3 ปีที่แล้ว

      @@Javatechie I did watch it more than once this a new concept to me & wasn't sure why you are returning 1 if you are searching for Banglore which doesn't exist in your DB returned data

  • @oluwafemisamueloyekunle3204
    @oluwafemisamueloyekunle3204 4 ปีที่แล้ว +1

    I have learnt a lot from you. Awesome tutorials

  • @kaishu8237
    @kaishu8237 3 ปีที่แล้ว

    on the 2nd test (starting 11:00), the dummy data address is "USA" and we are searching for "Bangalore", why it still come with 1 result? It should be 0 correct?

  • @mohamedabdelmaksood8732
    @mohamedabdelmaksood8732 3 ปีที่แล้ว +1

    great video, concise and very helpful.

  • @ganeshparida3794
    @ganeshparida3794 6 ปีที่แล้ว +2

    Awesome your effort please keep continue brother.

  • @azevedoedison
    @azevedoedison 2 ปีที่แล้ว +2

    Hi, very nice your video. In the example you used a list in FindALL. How would you test if you were a PAGE type? I can't find an easy test example.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Not sure need to check

  • @natetolbert3671
    @natetolbert3671 4 ปีที่แล้ว +1

    Persistent applications are especially important for which to write tests. You can have a functioning product which gives no errors, deploy said product, and then find out some time later that only half of your data persisted. Or even worse, that the DB overwrites itself each time the program is restarted.

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      Am not getting you . What you are trying to convey ?

  • @raisevoice1692
    @raisevoice1692 3 ปีที่แล้ว +1

    Great job brother👍👍👍

  • @YoursPravat
    @YoursPravat 6 ปีที่แล้ว +2

    Thanks Basant Bhai . You Rock.........................

  • @purnimakumari7735
    @purnimakumari7735 ปีที่แล้ว

    Thanks for sharing the knowledge. Please share how to test put method also.

  • @faizkazi8015
    @faizkazi8015 2 ปีที่แล้ว +1

    Hello Sir, Thanks for the session. It really helped just had some doubts.
    For creating test cases for DAO layer do we mock the methods without hitting db or should perform the db operation and then test?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      No you should mock all the db call

  • @thrinathsf1280
    @thrinathsf1280 6 ปีที่แล้ว +3

    Good explanation. I have one query, you explained unit testing from service to repository flow. What about end to end unit testing with mockito i.e Controller->Service->Repository ?

    • @Javatechie
      @Javatechie  6 ปีที่แล้ว

      Already I. Had one video to write test case for controller using mock MVC .
      It will be more difficult to show test case for all layer in single video.thats why I splited it as separate video.

    • @thrinathsf1280
      @thrinathsf1280 6 ปีที่แล้ว +1

      @@Javatechie ok thanks for the reply. is it possible to write unit tests from end to end using mockito ?

    • @Javatechie
      @Javatechie  6 ปีที่แล้ว

      Yes for all layer we can write like controller,service and repository I already uploaded 3 videos using mockito please have a look

  • @tulsi6317
    @tulsi6317 2 ปีที่แล้ว +1

    It's very clear.. thank you bro

  • @kevinnani5979
    @kevinnani5979 4 ปีที่แล้ว

    Very well explained I have one doubt like if user id is checking whether he is existing or not then how this dummy data will works?

  • @Telugu_Isleexplorer
    @Telugu_Isleexplorer 4 ปีที่แล้ว +1

    Nice and simple video

  • @pranavmahajan4190
    @pranavmahajan4190 3 ปีที่แล้ว +1

    Your videos are super helpful. Why dont you cover these videos in Hindi? This way you will explain it better and would be easy to grasp.

    • @manognajoshik8465
      @manognajoshik8465 2 ปีที่แล้ว +1

      It's about reachability. People not knowing Hindi will miss this valuable content

  • @abhinavpandey3356
    @abhinavpandey3356 2 ปีที่แล้ว +1

    In this did the delete method why we are calling service.deleteuser directly ? I guess we have to use when(service.delete()).then kind of syntax?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Here we are mocking the repository layer not the service layer buddy .

    • @abhinavpandey3356
      @abhinavpandey3356 2 ปีที่แล้ว +1

      @@Javatechie bro can u tell why we are deleting user which is not created in db?is it for verifying that whether repo is called or not?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      No it's just to check whether my delete method is working or not in service. It won't call your repo it will simply bypass dao call that is what the purpose of mockito right

  • @vanajan5622
    @vanajan5622 ปีที่แล้ว +1

    Thank you so much for the useful content

  • @nyesExpress
    @nyesExpress ปีที่แล้ว +1

    I'm fairly new to Java (and Spring). I see from the source code that 'UserRepository' is of type Interface. My understanding of @MockBean is that it instantiates an object of type 'UserRepository' within Spring's application container. But this is confusing to me, since I believe that Interfaces cannot be instantiated, only classes. So how does @MockBean instantiate an object of type 'UserRepository', which is an interface? Thanks for the great tutorial btw!

  • @sudheerreddymarreddy6903
    @sudheerreddymarreddy6903 3 ปีที่แล้ว +1

    Thanks for nice explanation.

  • @humeidjocordasse4605
    @humeidjocordasse4605 3 ปีที่แล้ว +1

    Thumbs up! before even seeing the video

  • @satyajitm93
    @satyajitm93 4 ปีที่แล้ว +4

    You wrote addrsss as "Bangalore". And in mock data there were no user with address Bangalore. Ideally it should fail because in asertEquals you wrote return value as 1.

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      Hi satyajit , Mention duration please didn't remember the syntax

    • @satyajitm93
      @satyajitm93 4 ปีที่แล้ว

      @@Javatechie 11:02 . Please check

    • @amanjain396
      @amanjain396 4 ปีที่แล้ว +1

      same doubt

    • @kishanlal676
      @kishanlal676 4 ปีที่แล้ว +2

      Yeah, I don't know how the test gets passed! It should return 0 as he didn't have any user with Bangalore as an address.

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว +1

      @@kishanlal676 & @Aman Jain no this is what mockito does , why you are expecting failure here if you observe when(dao.findUserByAddress(any)).thenReturn(Any user object) so irrespective of any address value i will get that user object which i mention in thenReturn , what's confusing you here

  • @flacodoom
    @flacodoom 3 ปีที่แล้ว +1

    Thanks for sharing this info.

  • @blasttrash
    @blasttrash 5 ปีที่แล้ว +2

    Should you only add tests for service layer? Or should you also add tests for "controller" and "data" layer also? Thanks

    • @Javatechie
      @Javatechie  5 ปีที่แล้ว +1

      We should write for controller layer , please check my mockmvc tutorial

  • @niharr7
    @niharr7 2 ปีที่แล้ว

    How to test the Data Layer ? There we won't use mockito ,right? Since we want to test the Data layer with actual values retrieved, inserted, updated and deleted from Database?

  • @rameshnaidu1908
    @rameshnaidu1908 ปีที่แล้ว +1

    i like that way u teaching

  • @utubeplaylist5784
    @utubeplaylist5784 2 ปีที่แล้ว +1

    Thank you sir. I have 1 question, when running 1st testcase, I understand what findAll() does, but when was those 2 entries inserted in mock repository?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      It's not inserted to dB those are mock Data

  • @prayagbhasin9192
    @prayagbhasin9192 2 ปีที่แล้ว

    Sir search is not working like you provide anything in adress it will give you same values you passes as parameters in return statement
    .thenReturn(Stream.of(new Post(values)));
    It must be like this if the address you provided matches then it will give values otherwise give empty as result but in both case it is giving exact same values

  • @codingispassion6376
    @codingispassion6376 2 ปีที่แล้ว +1

    Sir do you have any video on spring security? Can you please tell me about this? I am a beginner and i recently made a REST-API of payment wallet app using spring boot with jpa and now after watching this video I'll add mokito in it as well, it will be wonderful if you give me some idea about spring security so that I can add this too in my project.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Please check out the below complete video on spring security
      th-cam.com/video/5jDrBD4Y1MI/w-d-xo.html

    • @codingispassion6376
      @codingispassion6376 2 ปีที่แล้ว +1

      @@Javatechie Thank you so much sir

  • @Boebloegn
    @Boebloegn 3 ปีที่แล้ว +1

    insted of repository call if we need to call another service then also we need to use mock object??????

  • @Samiatrix
    @Samiatrix 3 ปีที่แล้ว +1

    Any idea like how can we test update method by Mockito

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Please checkout my reactive programming integration test and do follow same

  • @SayujyaShibin
    @SayujyaShibin 2 ปีที่แล้ว +1

    good vidoe..very helpful

  • @jarnailpanchal980
    @jarnailpanchal980 3 ปีที่แล้ว +1

    Thanks Sir! I also want to clarify test case for exception handling, So please upload a video for that as well...... Thank you so much sir.

  • @mugeeshhusain4498
    @mugeeshhusain4498 3 ปีที่แล้ว

    can you tell me when to use wevmvc test or when this service test?

  • @winmust2665
    @winmust2665 4 ปีที่แล้ว +1

    bhai bhala video heichi .......

  • @chinnapareddy8006
    @chinnapareddy8006 2 ปีที่แล้ว +1

    Thank you bro. It's really helpful and can you provide the depth knowledge for same like exception mocking part and if we have more parameters in method how we can handle.

  • @shubhamnayak668
    @shubhamnayak668 4 ปีที่แล้ว +1

    Very nicley explained
    Thanks

  • @sanu7611
    @sanu7611 3 ปีที่แล้ว +2

    When I run whole test class some methods are failing, when I run single test in class then it is passing.why so

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Check the exception it will give you hints otherwise if you are unable to find please share your GitHub link .I will check this out

    • @sanu7611
      @sanu7611 3 ปีที่แล้ว +1

      @@Javatechie is there are any methods to clear cache of unit test?exception is no value at json path but it pass individually when I run whole class this exception occurs

  • @krishnav902
    @krishnav902 3 ปีที่แล้ว

    You write test cases for one controller class.... If I want to write multiple control what I need to do...

  • @nikitanegi8669
    @nikitanegi8669 4 ปีที่แล้ว +1

    Hello. Like you have getByAdress method, i have a getById function that has a Optional return type. So, while writing test cases for it, it gives a type mismatch error while writing the when/then clause. Any ideas?

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      Optional.get() will give you object please do try with this

  • @niveshduppalapudi6885
    @niveshduppalapudi6885 2 ปีที่แล้ว +1

    clean explaination

  • @karthikb4023
    @karthikb4023 4 ปีที่แล้ว +1

    Your videos r very useful sir....

  • @divritsaini4993
    @divritsaini4993 3 ปีที่แล้ว

    Hi on line No 51 how you were able to do assertEquals on two objects. I had to override equals method and implement it to do equals as I was getting false because it was just comparing the reference value of those 2 objects.
    Please guide me on this.
    Thanks,

  • @seatconnect224
    @seatconnect224 2 ปีที่แล้ว +1

    also it would be good to say that there is no any sense to test JPA methods which provided for us as an API for free, because its already have been tested. But custom methods with @Query definitely should be tested.

  • @parthdubey1673
    @parthdubey1673 4 ปีที่แล้ว +1

    You have good concepts. Just work on communication. keep it up !

  • @Hacks00145
    @Hacks00145 2 ปีที่แล้ว +1

    Hey thanks easy to understand, but this is only the service classes, how do we do for overall project? Ex controllers, repos etc !!

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      For controller you need to use mockMVC already I uploaded that video

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      th-cam.com/video/fN8VAdYfJB8/w-d-xo.html

    • @Hacks00145
      @Hacks00145 2 ปีที่แล้ว +1

      @@Javatechie thank you 😀

  • @sk-fx3sk
    @sk-fx3sk 4 ปีที่แล้ว +1

    its simple, straight and Good

  • @kailashgujjar8662
    @kailashgujjar8662 3 ปีที่แล้ว +1

    Good explanation 👍

  • @VenuGopal-hg1hm
    @VenuGopal-hg1hm 4 ปีที่แล้ว +2

    Sir First of all I would like to appreciate your work it's really helpfull for the beginers.
    I am having one doubt :-
    @Test
    public void getUserbyAddressTest() {
    String address = "Bangalore";
    when(repository.findByAddress(address))
    .thenReturn(Stream.of(new User(376, "Danile", 31, "USA")).collect(Collectors.toList()));
    assertEquals(1, service.getUserbyAddress(address).size());
    }
    Here you are using address as Bagolore , But in the new User address as Danile , so since when we call service.getUserbyAddress(address).size() this you told that it won't touch db that's ok
    But that address is not matching naa so why it gives size as 1 , does this actually taking care of Banglore
    if yes please clarify it OR my thinking is wrong w.r.t to this topic
    Thank you SIR and Love u for your lectures

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      I commented on this please checkout once .
      when (repository.findByAddress(any)).then return(User object);
      So here it doesn't matter what address I gave , anything I can give it will return me the object which I mentioned in thenReturn method

  • @kritidas2140
    @kritidas2140 3 ปีที่แล้ว +1

    I have a question. If the save user test case does not save the data in database then why are we saving it?

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      While performing integration test we shouldn't persist data into actual DB .
      That's why people used mockito to by pass the flow

  • @avishekpaul8205
    @avishekpaul8205 5 ปีที่แล้ว +1

    Here in this case your mocking the repo class, but I cannot see where in your code you have created the DB connections ?

    • @Javatechie
      @Javatechie  5 ปีที่แล้ว

      Abhishek I would suggest you to first learn how we can connect database MySQL or mongo DB using spring boot .
      Here I used spring boot with mongo Database and all required datasource details configured in application.properties
      Here is the link to learn spring boot with mongodb
      th-cam.com/video/k5PeywcbVYc/w-d-xo.html

  • @nehapalnullRA
    @nehapalnullRA 4 ปีที่แล้ว +1

    What is the basic format of writing JUnit test case for @requestmapping in spring boot application?

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว +1

      You need to use MockMvc
      Please refer : th-cam.com/video/fN8VAdYfJB8/w-d-xo.html

  • @weekendhoppers
    @weekendhoppers 5 ปีที่แล้ว +1

    nice detailing thanks... is there a way that we test from controller API invocation directly?

    • @Javatechie
      @Javatechie  5 ปีที่แล้ว +1

      😊😊 Yes using mockMVC we can , already uploaded please have a look

  • @tushanemclean
    @tushanemclean 4 ปีที่แล้ว +1

    Let say you have function that returns nothing but u want to mock a service call that is being down with that function how would I do that?

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      You need to go for PowerMockito

  • @subhopaul6074
    @subhopaul6074 3 ปีที่แล้ว +1

    Can we write junit test cases for dto pojo and service layer separately ? But very useful video overall

    • @Javatechie
      @Javatechie  3 ปีที่แล้ว

      Yes we can write separate test case for service , dao and controller

  • @swapnilshrishrimal4520
    @swapnilshrishrimal4520 2 ปีที่แล้ว +1

    Thanks for this highly helpful video. How can we mock test IntegrationFlow in spring boot ? Any pointers to this is highly appreciated. Thanks!

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Mockmvc will helps you for integration test

  • @AhmadSayeed-plus
    @AhmadSayeed-plus 3 ปีที่แล้ว +1

    clean and well explained. Thanks man.

  • @fahadnadeem4295
    @fahadnadeem4295 2 ปีที่แล้ว

    Kindly please let me know if you have any video with the same content but for TDD development

  • @faizquazi292
    @faizquazi292 2 ปีที่แล้ว

    Hello Sir,
    Do we need to create test cases for entities and Dao classes as well or just service is fine since it contains all the business logic?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Yes service is enough

  • @firozgg7524
    @firozgg7524 5 ปีที่แล้ว +3

    when(repository.findall()).thenReturn()
    How did the value get changed into a stream of objects? was it a shortcut?

    • @Javatechie
      @Javatechie  5 ปีที่แล้ว +2

      It's inbuilt to mockito component, based on your when(argument return type) thenReturn() will always expect same return type

    • @mayurgaikwad2762
      @mayurgaikwad2762 4 ปีที่แล้ว +1

      @@Javatechie Will that gets automatically populated with dummy data or you pasted that data over there?

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว +2

      You need to pass data to that mockito method

    • @mayurgaikwad2762
      @mayurgaikwad2762 4 ปีที่แล้ว

      @@Javatechie Ok, Thanks

  • @umaparvathi606
    @umaparvathi606 3 ปีที่แล้ว

    Can you send the link for the next mockito kit series I don't find it please

  • @ViralShortsOfDuniya
    @ViralShortsOfDuniya 4 ปีที่แล้ว +2

    Class someClass {
    public void someMethod()
    {
    String str1 = someService.method();
    String str2 = someService2.method2(str1);
    syso( Str2.length() );
    }
    }
    How can i test this if my method is dependent on multiple service..
    And should i use mock or injectMocks?
    Please help

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว +1

      You should use either @MockBean or @InjectMock

    • @ViralShortsOfDuniya
      @ViralShortsOfDuniya 4 ปีที่แล้ว +1

      @@Javatechie should i use two when().thenReturn for above 2 dependent service?

    • @Javatechie
      @Javatechie  4 ปีที่แล้ว

      Yes

  • @solankijigar11
    @solankijigar11 3 ปีที่แล้ว +1

    Thank you very much, sir. Great explanation. :)