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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -