PowerMockito.whenNew not working on android's Intent class -
i trying use mock intent object when using whennew powermockito, not able mock constructor. have tried possible combination of arguments, doesn't work.
i had similar problem, , solution found in answer.
to more specific: please try add @preparefortest
annotation @ test or @ class level, , provide class constructs intent.
public class someclassthatcreatesintent { public void somemethodwithintent() { intent = new intent(); } }
and test class should this:
@runwith(powermockrunner.class) @preparefortest({someclassthatcreatesintent.class}) public class someclassthatcreatesintenttest { @test public void test() { // test uses powermockito.whennew(intent.class) } }
hope help.
Comments
Post a Comment