When I search any topic on youtube and I see Tech Primers' video on it, I click it immediately.
@wallysonruan2 жыл бұрын
Thank you! I've gone through a lot of Udemy courses and none of them helped me so much as you did. Keep up the good work!
@SyamKumarVoleti4 жыл бұрын
Thank you for the wonderful presentation. I believe you are a life saver for many victims who struggle to understand Junit test cases.
@AmitSingh-vb6oj5 жыл бұрын
To add - if your controller function is using some service class (which is most likely) then one needs to add @Mock ControllerService controllerService Before invoking test function
@faheemazfar30593 жыл бұрын
A perfect, precise, and clean tutorial.
@rakeshbhagat1234 жыл бұрын
I have said this before as well. You don't drag things and finish the course in quick time and make sure everything is covered in detail. Thank you
@TechPrimers4 жыл бұрын
Glad its useful Rakesh
@rrafaelpaz5 жыл бұрын
Great video mate! Appreciate the time to share it with us!
@miguelrico43386 жыл бұрын
You are one of the best teachers on youtube! Love the content it's been really helpful!
@TechPrimers6 жыл бұрын
Thanks Miguel. Glad that was useful
@altjedan70675 жыл бұрын
Thank you a TON. This was literally what i was looking for. Clean, detailed and precise tutorial. Respect.
@madhug823 жыл бұрын
nice one. Its very crisp and to the point. Thanks for the nice video. Keep rocking with more videos like this!!
@ovey22142 жыл бұрын
This is exactly what I've been looking for! Thanks for making this!
@123rubyg3 жыл бұрын
Solid and crisp explanations.
@jasper50163 жыл бұрын
Can you please cover these tests with Junit5? I think lot of these things are changed.
@aishwarykumar47215 жыл бұрын
Very good Explanation of basic concepts great for beginners to start with.
@Ravikirankada5 жыл бұрын
Unique and awesome video. Please can you create a playlist on JUNIT testing with some complex REST Example.
@yashobantamajhi86266 жыл бұрын
Nice video for mockito. How to mock a end point of a controller which involves a interface.
@weekendhoppers5 жыл бұрын
looking for same.... any suggestion?
@kvchahar103 жыл бұрын
Thanks a lot, it is very helpful for me to understand clearly about the testing from Mock MVC.🙏
@anand2009ish3 жыл бұрын
Very intersting...👍👍👍👍👍
@sathishrao79265 жыл бұрын
Nice and simple introduction.
@mohammedshabbir13472 жыл бұрын
Awesome Tutorial.
@MrLangam6 жыл бұрын
Wow, even though you have an odd accent, you seem to know what you are talking about unlike other indian youtubers out there who just mumbles stuff. Thanks!
@motolola6 жыл бұрын
Very nice Tutorial, was wondering about Testing Crud operations the same way.
@veerendrabanka99075 жыл бұрын
Very good and detailed explaination
@gaurav-javatechgeek9354 жыл бұрын
thankyou , it was really help full, could you please provide some more videos for this
@abhilashsulibela14146 жыл бұрын
Love the content. Simply brilliant
@muks6 жыл бұрын
Can you add a test for writing a JUnit test case for ResponseEntity also? It is very useful as real world uses response entity to return response. Much appreciated. Thanks
@Wind-on-myFace3 жыл бұрын
Found Useful in 2020!
@muks6 жыл бұрын
Really Awesome video. Learned a lot. Good Job man.
@LearnWithAbubakr Жыл бұрын
Very nicely explained.
@pratikmukane76316 жыл бұрын
Very very helpful tutorial video..
@balank23673 жыл бұрын
Thanks for the video mate
@carlchan59316 жыл бұрын
Could you make a new video using junit 5? I get stuck at initiating the test class
@Saurabh28163 жыл бұрын
Guys the test cases described here are called integration test cases or unit?
@ranjan0982 жыл бұрын
how to test the Repository class methods. please post a tutorial.
@Harsh_H_Patil Жыл бұрын
Hey can you please write some junit for post methods as well
@e.ch.vidyasagarkorada73413 жыл бұрын
Really helps lot #KnowledgeSharing thank you @TechPrimers
@nehapalnullRA3 жыл бұрын
The video was really helpful. thankyou. i am working on writing junit test case for controller where i have to test for not a single entity but a list as a whole using jdbc template. how do i do that? i tried using object mapper, but i see errors while using it.
@umeshdhaked17033 жыл бұрын
Hey, it's easy to do it with spring boot which already comes with tomcat builtin, but how do you unit test API in spring mvc ? can you make video on that ?
@TechPrimers3 жыл бұрын
Unit tests are at the class level. So essentially testing an API mostly will have mocked classes. If you have services or DAOs, then you will need to have unit tests at each level. So unit testing doesn't fall under API level umbrella
@brianocorner56046 жыл бұрын
Hi Buddy, It is an awesome demo. But I have a doubt, In this video you are testing every URL with the data given in your rest method, but we can not provide hard code value in our controller. So, how can we provide mock data and test with that value? A quick response will be greatly appreciated. Thank you in advance.
@TechPrimers6 жыл бұрын
Yes Brian. In that case you can have the JSON value separated out in a file and compare the content
@nivz935 жыл бұрын
@@TechPrimers Can you give an example how we can compare a json file stored int test/resources to the json response received by the api
@andrzejokon15176 жыл бұрын
Good tutorial. Thank you !
@SportAnalysisKing6 жыл бұрын
AspectJ for AOP will be very awesome if you can do it. Thanks
@TechPrimers6 жыл бұрын
sure
@basmaradadi91554 жыл бұрын
Hi , why you didnt have w service layer in ur project
@MegaRockingraj6 жыл бұрын
Hi brother, Could you share any content for writing positive and negative mockito test cases scenario for two tables which is related as many to one mapping. E.g., like many student belong to one department. Thanks.
@nareshgoud92255 жыл бұрын
While running test case in eclipse getting socket connect timeout error how to resolve it?
@juliusvm61165 жыл бұрын
What about if the HelloResource are using a real service? How do you mock that?
@Skiamakhos6 жыл бұрын
This is great - but how do you do this if you're working on an existing project that doesn't use Boot & won't be using it in the foreseeable future?
@TechPrimers6 жыл бұрын
If you are using Spring REST, then you can use it the same way
@manojvakkala96995 жыл бұрын
Getting NullPointerException, why> and how to solve pls explain
@bhaskarbanepali85654 жыл бұрын
Hello Sir, can you upload a video teaching how to write the JUNIT test cases for the methods(which has 2 or 3 business logics ) returning VOID?
@bhaskarbanepali85654 жыл бұрын
Please notify me at shrumsowen1@gmail.com
@guruprasad69825 жыл бұрын
child example, bro in controllers we have service dependency and in service will be having respository dependency in your example those things were skipped, how to do integration test through mock mvc?
@AdityaRajVerma5 жыл бұрын
Awesome but how to write unit test cases for a rest api which system depended to generate response.mine is a rest end point which only runs in suse linux environment but we do development on windows platform
@TechPrimers5 жыл бұрын
you will have to mock those system dependent responses or you need a Continuous Integration server which is based on suse linux env.
@AdityaRajVerma5 жыл бұрын
@@TechPrimers thanks a lot.you are awesome.keep up video making
@nsmaepa5 жыл бұрын
Is it possible to write test cases for SOAP endpoints? if Yes, can you make a sample video for that as well? Thank you
@TechPrimers5 жыл бұрын
Sure will do mate
@nsmaepa5 жыл бұрын
@@TechPrimers Thank you
@amritaeternalspirit5 жыл бұрын
@@TechPrimers Can you explain this to me please. If you had to create the object with the builder, then what did injectmocks do ?Same helloresource you injected as well as created with builder. Can you please help me understand? Thank you very much.
@magichatake5 жыл бұрын
In my STS just gives "NullPointerException". I have the same code but the result is the same
@Andrewtmcb5 жыл бұрын
you probably have dependencies you are not satisfying. You need to mock every other service. This was from four months ago but let me know if you still have some confusion and we can discuss.
@zishan-khan4 жыл бұрын
@@Andrewtmcb Hi Andy I am having the problem. I did everything as mentioned in the video but I am getting Null Pointer Exception
@monikasinha478 Жыл бұрын
Thanks a lot sirji
@ninja_ape3 жыл бұрын
Testing with Profiles?
@privateuse41574 жыл бұрын
Failed to load Applicationcontext why I’m getting this error?
@mansinigam79764 жыл бұрын
Thanks for this video.
@veerendrabanka99075 жыл бұрын
Good explaination
@santhoshisunaina33643 жыл бұрын
Perfect🔥
@BitByteGb3 жыл бұрын
sir please, extend this video with jpa as well
@chetanm8985 жыл бұрын
This test applies for all controller,service and repository layers?
@sauravchaudhary72454 жыл бұрын
Its throwing NullPointerException on this mockmvc = MockMvcBuilders.standaloneSetup(helloController).build(); mockmvc is coming null.
@SameeraSenarathna5 жыл бұрын
Thank you. very Helpful
@dileepalla67697 жыл бұрын
THQ tech primers
@JohnWick-zc5li7 жыл бұрын
thanks tech primers
@arunnambiar117 жыл бұрын
I get stuck while running the test for first time with this error "java.lang.AssertionError: Status expected: but was: at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:54)". Any clue on what could be wrong - code is exactly the same as yours ?
@TechPrimers7 жыл бұрын
This error occurs when either your rest url is wrong or when your server is not up or if the RestController is not identified by SpringBoot during startup
@privateuse41574 жыл бұрын
how do we load properties file
@nehakumar9889 Жыл бұрын
thank you so much
@makxell6 жыл бұрын
im geting the error "the method get(String) is undefined for the type HelloResourceTest" in line 36. same for "status()"
can you use MockMvc to test an application which is not built using Spring
@indranilbanerjee78706 жыл бұрын
NO
@erickloningo22525 жыл бұрын
awesome
@Rahulkushwaharahul6 жыл бұрын
Brilliant bro :)
@raghadabugharbieh9445 жыл бұрын
greatt videoo thank youu so muchh
@KK-tz5fr5 жыл бұрын
thanks a lot
@MrLangam6 жыл бұрын
How about for nested json?
@TechPrimers6 жыл бұрын
you can try this: stackoverflow.com/questions/15371022/springmvc-mockmvc-jsonpath-compare-list-of-strings
@vikasmessi5 жыл бұрын
Hi, I am facing an issue when running my test with @Valid and Errors handler on controller. It gives illegal state exception although i the Errors interface is called after the request body.
@JohnWick-zc5li7 жыл бұрын
how write test a contoller that calls a service method
@ainuddinb7 жыл бұрын
You can autowire the service in test class.
@TechPrimers7 жыл бұрын
If you are aiming to do only JUnit, then you can annotate the service with @Mock in the test and mock the service calls using Mockito.when() and verify them using Mockito.verify()
@TechPrimers7 жыл бұрын
Hi John, I have made a video on mocking the Service methods. Check it here: kzbin.info/www/bejne/f5vNZoWCiKaWj9k
@balank23673 жыл бұрын
April 2021: With latest spring version: 2.4.4, below code works. @ExtendWith(SpringExtension.class) @WebMvcTest (HelloResource.class) class RestControllerTestApplicationTests { @Autowired private MockMvc mockMvc; @Test void contextLoads() { } @Test public void test() throws Exception { mockMvc.perform(get("/hello")) .andExpect(status().isOk()) .andExpect(content().string("hello World")); } @Test public void testJson() throws Exception { MvcResult mvc = mockMvc.perform( get ("/hello/json").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect( jsonPath("$.title").value("Greetings") ) .andExpect(jsonPath("$.value").value("Hello World") ).andReturn(); Map objectMap = JsonPath.read(mvc.getResponse().getContentAsString(), "$"); assertEquals(2, objectMap.keySet().size()); } }
@ashoksurabhi57316 жыл бұрын
please upload a video on JUnit Tests for Multipart file upload using MockMvc......like for @PostMapping("/signSetupWithImage/{id}") public String initSetUpConfiguration(@RequestParam("file") MultipartFile file, @PathVariable Long id)
@agnihotriashish4 жыл бұрын
Way too many ads :(
@ranjeetsahani92076 жыл бұрын
Good content
@TechPrimers6 жыл бұрын
+ranjeet sahani thanks Ranjeet
@chrisnolan82635 жыл бұрын
Why is there a background music? That's annoying af