PacktPublishing / Microservices-with-Spring-Boot-and-Spring-Cloud-2E

Microservices-with-Spring-Boot-and-Spring-Cloud-2E, Published by Packt
MIT License
237 stars 260 forks source link

How to run WebTestClient test with debugger #2

Closed andreykirson closed 3 years ago

andreykirson commented 3 years ago

Could you tell me how to run the WebTestClient test with the debugger? I mean if I want to debug RecommendationServiceImpl while running the test I put a stop point in the getRecommendationByProductId() test and in RecommendationServiceImpl, but when the test is run it does not go to RecommendationServiceImpl and I can not see how it works.

image image

magnus-larsson commented 3 years ago

Hello Andrey and thanks for reporting this issue!

I tried running the test in the debugger, using IntelliJ 2021.2, and the execution stopped at the breakpoint in the getRecommendations method as shown in this screenshot:

Screenshot 2021-09-14 at 08 02 21

From looking at your screenshot it seems like your breakpoint is set inside the if statement for negative productIds. Since the productId is set to 1 in this test, your breakpoint will never be reached and therefore the debugger will not stop the execution.

Could that be the reason?

Will the debugger stop on a breakpoint set on the If statement (as shown in my screenshot)?

andreykirson commented 3 years ago

Hi, Larsoon. Thanks a lot for the operative answer. Yeah, you are right just changing the stop point helped fix it.