#Testing - Spring & Java
1 messages · Page 1 of 1 (latest)
<@&1004656351647117403> please have a look, thanks.
You can use mockito with JUnit.
JUnit, Mockito, AssertJ, Testcontainers, awaitility and datafaker are some pretty commonly used libraries.
Oo, some of those are new to me - will need to go through those
Do you have any sample repos I can refer to which test rest apis? (really - really extensively, as if it was a large rest api)
everything from data validation, response codes, json serialization, database schema etc?
I'd start easy with https://github.com/spring-projects/spring-petclinic .
Also how do I decide whether to use TestRestTemplate or something a bit more low level (?) like mockMvc? the resttemplate testing code seems more concise and cleaner - from what I'm seeing the only difference is that mockMvc doesnt have the server overhead
I'd recommend looking at https://spring.academy/courses .
Just relying on mocks truly is often not the most efficient way to test code. Should data access code mock out the database? Should a GraphQL or REST service just test its data fetchers as Java methods? You will not only learn why the answer to these questions is often “no”, but you will learn the techniques to best test such code. You will lear...
I currently have the petclinic repo open side by side haha and I'm going through the spring.academy learning path - my only gripe is the mismatch between the way both do things, academy uses @RestController and a simpler design
altho thats probably a good thing lol, the spring.academy course was a bit on the simpler side so maybe I just should understand petclinic properly
Thanks for all these resources, for some context I'm coming over from the Python world and connecting the dots have been fun - recently started an internship where they're making us build a spring app to learn in 2 weeks (!) and god I wish I could just do deep-dives into stuff without having to rush through things, hate having half the picture of things