I want to write some unit tests and instrumentation tests for my android project.
However, I've met a problem that stuck me a while... I need to mock a static method and fake the return value to test the project.
After survey from some forums, the only way to do this is to use PowerMock to mock the static method.
This is a part of my gradle:
androidTestCompile "org.powermock:powermock-module-junit4:1.7.0"
androidTestCompile "org.powermock:powermock-module-junit4-rule:1.7.0"
androidTestCompile "org.powermock:powermock-api-mockito:1.7.0"
and my test class:
@RunWith(PowerMockRunner.class)
public class MyClassTest {
...
}
Then I got "java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;" in PowerMock...
It seems android sdk had removed some Class in java.beans.* https://developer.android.com/reference/java/beans/package-summary.html
How can I mock or fake the static method return values?
Thanks a lot.