当我在清单中添加 Facebook SDK 和 applicationId 时,Espresso 测试不起作用如果类中有多个测试方法,则错误仅发生在第一个测试中
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
Run Code Online (Sandbox Code Playgroud)
导致 AppNotIdleException 异常
E/TestRunner: androidx.test.espresso.AppNotIdleException: Looped for 2 iterations over 60 SECONDS. The following Idle Conditions failed .
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:94)
at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:57)
at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:316)
at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:177)
at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:118)
Run Code Online (Sandbox Code Playgroud)
如果我从清单中删除,com.facebook.sdk.ApplicationId测试将正常运行
安卓测试版本:
ext {
kotlin_version = '1.3.31'
koin_version = '2.0.0-rc-2'
nav_version = '2.0.0'
arch_version = '2.0.1'
retrofit_version = '2.5.0'
lifecycle_version = '2.0.0'
glide_version = '4.9.0'
espresso_version = '3.1.1'
}
Run Code Online (Sandbox Code Playgroud)
// Facebook
implementation 'com.facebook.android:facebook-login:4.42.0'
// …Run Code Online (Sandbox Code Playgroud)