https://kotlinlang.org logo
#mockk
Title
# mockk
a

Adam Pelsoczi

07/28/2022, 8:10 AM
I am getting a
RuntimeException
when unit tests execute any code which has a public static function written in a java class file (
Log.d
,
ParcelUuid.fromString
,
Instant.of
)
Copy code
Method d in android.util.Log not mocked. See <http://g.co/androidstudio/not-mocked> for details.
java.lang.RuntimeException: Method d in android.util.Log not mocked. See <http://g.co/androidstudio/not-mocked> for details.
https://gist.github.com/apelsoczi/497a8f002d78da0bb5121b94755b868c Here's a gist of two files. Within the
CoroutineUseCaseTest
there is a
ExceptionUseCase
which extends
UseCase
and invoking
Log.d(TAG, "invoke: ", e)
causes the above error. I am baffled at why what is documented to mock a static java method is not working. Every post I read online says to
mockStatic(
) and write
every {}
in an
@Before
annotated method.
213 Views