I couldn't find any info on how to setup powermock with Android Studio/Gradle. Everything I've tried resulted in build exceptions.
Could anybody show a correct way to do it?
Thanks.
I couldn't find any info on how to setup powermock with Android Studio/Gradle. Everything I've tried resulted in build exceptions.
Could anybody show a correct way to do it?
Thanks.
In the build script, add the following:
Then, do gradle unitTest from the command line.
Hope that works. If it doesn't, post the output of the command line.
I have used same as @Bhargav used with some additional features added with it
Add this marked lines in build.gradle to enable
JUnit, PowerMockito, JaCoCo
I'm posting in order to help future readers, you need to add these dependencies for powermock in AS
Add the following lines to your dependencies{} block:
And if you would like to use PowerMockito, add the following line:
If you want to use more recent versions of Mockito, you can use something like this, which is adapted from the mockito 2 Powermock docs. Do make sure you use the right version of PowerMock for the given version of Mockito.