Thanks for the simplest explanation of mocking rest services using Sprint Junit Runner.
@TechPrimers6 жыл бұрын
thanks naval
@vamshikrishna81436 жыл бұрын
power mock for static and private methods would be a great addition.
@navidgalt22446 жыл бұрын
Very nice video! Can you show how to create tests for a POST method for REST services (passing headers and a body) with SpringMVC?
@shruthishru35532 жыл бұрын
Very helpful, easy to understand, thanks 😊
@sureshdhulipudi6005 жыл бұрын
How to mock Rest Template, i.e in service layer we r consuming rest end point
@abhilashsulibela14146 жыл бұрын
Awesome content. Please keep making more!
@tw55293 жыл бұрын
Awesome 👍😊 . If there will be a Controller Interface and all the methods iside Interface will be annotated with @GetMapping or @PostMapping . Controller class implements that Controller Interface.Then what exactly do we need to make change here??
@lalitkulkarni67686 жыл бұрын
Not all post methods return back some json. Thus it becomes important to understand how to write a junit test in a scenario when we have a post method which inserts some data in the database by the route Rest controller --> Business --> Repository. This method doesn't return back any data. Can you please mention what should be the assertions or checks in this case? And what needs to be mocked in such cases.
@AshishGupta-rh3jf6 жыл бұрын
I was struggling to write test cases for services. Thanks a lot for this video. Can you help to prepare for C# restful services testing.
@rossayer77293 жыл бұрын
The music listed in the description is not what I'm hearing in the video. Where do we find the song playing in the video? Edit: Found it in another Tech Primers video: Lowrider, Luvly - Joakim Karud
@VivekSharma-qs6qp5 жыл бұрын
Hi dude. At 2:48 You show that how we can use thenReturn() method to provide the response of the helloService.hello() method. In my case, I have a custom object that is being returned instead of a plain string. How to specify it in the thenReturn method?
@raaghaviravisankar18533 жыл бұрын
How is it returning hello it should return hello world right since it specified in service?
@koushivlogs775 жыл бұрын
Hi..excellent tutorial for beginners. Please create video on 100 percentage test coverage for a pojo annotated with lombok
@jasper50163 жыл бұрын
Its good information but can you cover Mockito testing of CRUD operations? It would super helpful
@kirann94334 жыл бұрын
how to write test case for multipart file as input for post request parameter
@basmaradadi91555 жыл бұрын
Hi , in ur folder's project in github it missed some files (like the model ..) please check it thnks
@jsloth03034 жыл бұрын
awesome video !
@narasimhareddy09076 жыл бұрын
Can you provide junit for jdbctemplate with mockito
@richardlanglois51836 жыл бұрын
Very useful presentation!
@1mallareddy5 жыл бұрын
Can anyone help me in, how to add headers, params to the request if possible including basi auth? Any videos/link is appreciated, Thanks in advance :-)
@bhargavkommu94237 жыл бұрын
Hi.. can I request you to give an example on power mock for static and private methods
@TechPrimers7 жыл бұрын
sure. will do bhargav.
@dileepalla67697 жыл бұрын
can u post an example on how to perform logging in spring mvc ,hibernate and create a war file and deploy into server and junit test cases and add to hoe to add repository svn or git post one bigger example
@TechPrimers7 жыл бұрын
Sure Dileep. I will do one soon.
@ainuddinb7 жыл бұрын
Very useful :) Thank you.
@TechPrimers7 жыл бұрын
thanks ainuddin
@gaurav-javatechgeek9354 жыл бұрын
could you plese provide more vieos like crud operation Mock testing for Rest controllers?
@JohnWick-zc5li7 жыл бұрын
thanks for vidoes -- how mock a final class, interface, & static method..
@TechPrimers7 жыл бұрын
+John Wick you can use PowerMock to do that. I will see if I can do a video on that
@javatar48097 жыл бұрын
Please make videos on testing RestController in spock framework...
@TechPrimers7 жыл бұрын
Sure Javatar, Will do
@mudassir31746 жыл бұрын
Hello sir, please show how can we check for XML
@TechPrimers6 жыл бұрын
sure
@yqevawang18647 жыл бұрын
Nice post!
@TechPrimers7 жыл бұрын
Thanks yqeva
@midasama31244 жыл бұрын
It looks pretty straightforward with dummy JSON files, but I would love to see a video with a real database!
@lajos-berenyi4 жыл бұрын
Hi Miguel! What you are asking for is not anymore a Unit test, but functional test, what can be done mostly with selenium, or trying the application with postman, etc. The Unit test is testing only a logic of a particular method of particular class. For example in his case we just testing the logic in the methods of the HelloResource class. Here we don't test the logic placed in the dependencies, so we here just mock them and only check if they where called (verify in the video). If we would like to test the logic in the HelloService, we make the separated test class for that, where we only test the logic in the HelloService, etc. So similarly if we use a Dao or Repository for DB operations, in the Unit test we don't really connect to the DB, we only mock the Dao or the Repository class, but we can check if their methods are properly called.
@midasama31244 жыл бұрын
@@lajos-berenyi Hi Lajos. I really appreciate your extensive and fully descriptive explanation. I am still struggling with these concepts regarding software testing. I get your point that my request gets out of the scope of unit testing, but I just don't see the point of testing simple CRUD operations (at least in my case) on a DAO or JDBC template mock. I would rather just skip that and test the overall functionality on a real database. For the moment, I just don't know to what extent unit testing may become rather unnecessary, and when it would be good practice to implement it.
@lajos-berenyi4 жыл бұрын
@@midasama3124 I will write a simple example of CRUD Unit test (the unit test is testing the logic and not the data), for exsmple the Create method: we mock the repository and checking if in the post controller method the repository's save method was called with the correct parameter, and checking the correct answer of the post method. Also we write a test, that if the repository throw an exception (means the data isn't saved to the DB), the post method also throw an exception or check that despite of saving exception the post method doesn't throw an exception but will answer with not 200 status, but with some 400+ status and give answer some errorResponse json. This how the unit test works in practice.
@lajos-berenyi4 жыл бұрын
@@midasama3124 Here is a code example, what I was talking about: drive.google.com/file/d/1CF8KN9acbWAmFSMzHtfXDVn4-gJTGnX7/view?usp=sharing
@smithdragon64774 жыл бұрын
Why not wiremock
@smithdragon64774 жыл бұрын
I was struggling with wiremock and this way to mock rest
@tarunsapra19307 жыл бұрын
Hello guys, Nice video but you have used an old technique to test controlllers. Spring boot offers much easier and more intutive way to test the Controllers. Just use the annotation @WebMvcTest and for mocking the service just use @MockBean annotation and @WebMvcTest also auto-configures MockMvc which offers a powerful way of easy testing MVC controllers without starting a full HTTP server.