FirebaseMessagingService 在 Instrumentation 测试时自行启动
FirebaseMessagingService launch itself when Instrumentation test
当我尝试 运行 Instrumentation 测试时,class 扩展的 FirebaseMessagingService 会自行启动,导致测试崩溃,因为其中的领域尚未准备就绪。我在我的应用程序 class.
中初始化领域
有没有办法阻止 Firebase class 在测试时自行启动?
错误信息:
java.lang.RuntimeException: Unable to create service .gcm. FirebaseMessagingService:
java.lang.IllegalStateException: Call `Realm.init(Context)` before creating a RealmConfiguration
AndroidManifest.xml:
<service android:name=".gcm.FirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
它唯一被调用的地方是扩展 class 中的 Dagger2 注入。
private val component: FcmServiceComponent by lazy {
GetApplicationComponent.execute(this).fcmServiceComponent()
}
这是因为我的自定义应用程序在代码中打开它。
所以先检查自定义应用程序中的内容,然后再检查这里。
当我尝试 运行 Instrumentation 测试时,class 扩展的 FirebaseMessagingService 会自行启动,导致测试崩溃,因为其中的领域尚未准备就绪。我在我的应用程序 class.
中初始化领域有没有办法阻止 Firebase class 在测试时自行启动?
错误信息:
java.lang.RuntimeException: Unable to create service .gcm. FirebaseMessagingService:
java.lang.IllegalStateException: Call `Realm.init(Context)` before creating a RealmConfiguration
AndroidManifest.xml:
<service android:name=".gcm.FirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
它唯一被调用的地方是扩展 class 中的 Dagger2 注入。
private val component: FcmServiceComponent by lazy {
GetApplicationComponent.execute(this).fcmServiceComponent()
}
这是因为我的自定义应用程序在代码中打开它。
所以先检查自定义应用程序中的内容,然后再检查这里。