how to stub the method which is being called inside the constructor?
for a class im testing, it has parameterized constructor and in that there is a method being called, i tried to stub using doReturn().when.class.function but it doesnt stub it, the function always gets ran. So to stub these kind of functions is there any other way
4 Replies
⌛
This post has been reserved for your question.
Hey @Dymension! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
What junit version are you using?
Are you using Mockito? Can you show the relevant code?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.