具有预期(hasComponent(...))的Espresso测试在API 28上失败

时间:2018-11-17 21:24:59

标签: android android-espresso

我们的测试通过了API 27

但是在API 28上,我们在所有具有intended(hasComponent(MyActivity.class.getName()));的Espresso测试中都遇到了此错误

我看到了this answer,但是我们已经在使用buildToolsVersion '28.0.3',我也迁移到了AndroidX,没有任何麻烦。

Stacktrace:

android.support.test.espresso.base.DefaultFailureHandler $ AssertionFailedWithCauseError:想要匹配1个意图。实际匹配0个意图。

IntentMatcher: has component: has component with: class name: is "com.mydomain.myapp.activity.MyActivity" package name: an instance of java.lang.String short class name: an instance of java.lang.String

Matched intents:[]

Recorded intents:
-Intent { flg=0x14000000 cmp=com.mydomain.myapp.qa/com.mydomain.myapp.activity.ActivityB } handling packages:[[com.mydomain.myapp.qa]])
-Intent { cmp=com.mydomain.myapp.qa/com.mydomain.myapp.activity.ActivityC (has extras) } handling packages:[[com.mydomain.myapp.qa]], extras:[Bundle[{utm.content=null, goto.signup=false}]])
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:88)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:51)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:314)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:297)
at android.support.test.espresso.intent.Intents.intended(Intents.java:188)
at android.support.test.espresso.intent.Intents.intended(Intents.java:169)
at com.mydomain.myapp.activity.CCFailureTest.activeLowRiskUserCanCloseUpdateCCPopupTest(CCFailureTest.java:92)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at android.support.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:61)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:527)
at android.support.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:129)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at android.support.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:101)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
Caused by: junit.framework.AssertionFailedError: Wanted to match 1 intents. Actually matched 0 intents.

0 个答案:

没有答案