关于Android Studio单元测试中“Method d in android.util.Log not mocked.”问题的解决

关于Android Studio单元测试中“Method d in android.util.Log not mocked.”问题的解决。

一般发生在 Robolectric 3.x 版本上,比如 Robolectric 3.8

解决方案:

打开对应模块的build.gradle文件

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

参考链接


关于Android Studio单元测试中“Method d in android.util.Log not mocked.”问题的解决。