WebMvcTest not generated for controller class

Tried to generated test case using diffblue cover for class annotated with @RestController and @RequestMapping but diffblue is generating test class annotated with @ContextConfiguration instead of @WebMvcTest . This is causing improper test cases . Please suggest

Hello,

Thank you for contacting Diffblue with this issue. In order to be able to assist, we would kindly ask you to upload the source code for the class being tested and, if possible, the log file generated while DCover writes the corresponding test class.

Kind Regards.
Cristian

Hi cbontoiu,

PFA - target java class , test file generated and log file

DCover.log (26.0 KB)
[DCover.Src.Java.Class.txt.log|attachment](upload
generated_test_by_dcover.txt.log (2.9 KB)
://yKCmqhzk5YXFdnJgxx8m9pSFzRQ.log) (1.6 KB)

Hello again on this issue. Thank you for sending us the two log files. It would help if you could attach the controller (not service) source code which you try to test, and the corresponding test class written by DCover. Kind regards, Cristian

Hi PFA . I have renamed java files to .log to allow it uploaded.
And yes, thanks for your quick follow-ups.
[cover-server.log|attachment](uploa
S2SAuthController.java.log (4.0 KB)
S2SAuthControllerTest.java.log (6.7 KB)
d://crXL1CDfD5agL4IfkeJcXuZ0wDy.log) (2.6 KB)

Hi!

Thank you for sharing the source code with us. We have investigated the code and tests and can confirm that the annotations Diffblue use test the functionality in the same way as @WebMvcTest . It uses @ContextConfiguration and then the MockHttpServletRequestBuilder and MockMvcBuilders to the same effect as @WebMvcTest. To help us understand more about your problem please can you explain why you need tests to use @WebMvcTest?

Kind Regards,
Cristian

Ya but when I am debugging, it does not go into the controllers method … looks everything is mocked. But when I write using webMvcTest annotation , I can go inside each method while debugging. At top view, it looks same but I don’t know internally where the deviation is coming . MockMvc and MockMvcBuilders are not working same under separate annotation at the top of the class.

Hello and thanks for coming back with clarifications.

Please, could you let us know whether you are trying to test the S2SAuthService, and, if this is the case, that you have the Diffblue Setting option selected as in the image attached. If that option is checked and the issue persists, please let us know and we will try to help.

Kind Regards,
Cristian

Cristian, give me sometime, will get into more details on generated test and come back if there is any further query.