#how to stub the method which is being called inside the constructor?

5 messages · Page 1 of 1 (latest)

muted storm
#

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

craggy gustBOT
#

This post has been reserved for your question.

Hey @muted storm! Please use /close or the Close 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.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

topaz matrix
#

What junit version are you using?

sonic furnace
#

Are you using Mockito? Can you show the relevant code?