#Testing a REST-API i java

1 messages · Page 1 of 1 (latest)

sleek bear
#

Hello, im very new to Java and want t olern how to write unit tests for a REST-controller in springboot.

When i google i get two different approaches, either mocking the controller using mock and just calling the methods OR i see the alternative way of using mockMvc and calling the actual endpoint.

Which is the way to go if you want to write "unit test"? Or do you usually do both ways?

Thanks in advance 🙂

vital graniteBOT
#

<@&1004656351647117403> please have a look, thanks.

vital graniteBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

undone vortex