It can help you: Unit testing on Android Studio: "not mocked" error
Text from your link(sorry, i can't set this post as a comment) :
Note that when running tests from Gradle, we will execute tests for
every variant of your code (see here). This means that tests will end
up executing at least twice (once with the release build of your code,
once with the debug build of production code).
"Method ... not mocked."
The android.jar file that is used to run unit tests does not contain
any actual code - that is provided by the Android system image on real
devices. Instead, all methods throw exceptions (by default). This is
to make sure your unit tests only test your code and do not depend on
any particular behaviour of the Android platform (that you have not
explicitly mocked e.g. using Mockito). If that proves problematic, you
can add the snippet below to your build.gradle to change this
behavior:
android {
// ...
testOptions {
unitTests.returnDefaultValues = true
}
}
We are aware that the default behavior is problematic when using
classes like Log or TextUtils and will evaluate possible solutions in
future releases.