Anyone know if its possible to use Mockk to mock a...
# android
a
Anyone know if its possible to use Mockk to mock android.util.Base64 ?? I have 2 static functions encrypt and decrypt and would like to write unit test for them. https://stackoverflow.com/questions/55603438/mocking-java-base64-with-mockk
g
Instead of mocking this class, just provide own abtraction for Base64
a
??? Not sure I understand the error I get is ```
java.lang.RuntimeException: Method decode in android.util.Base64 not mocked. See http://g.co/androidstudio/not-mocked for details. at android.util.Base64.decode(Base64.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
g
Yes, because you use framework class in unit tests
There are few different workarounds for this, such as add Base64 implementation to your project and do not use framework, abstract this API