相关疑难解决方法(0)

如果没有按钮,Espresso不会记录任何意图

我正在尝试编写一个测试来验证使用espresso启动意图,问题是目标()没有记录任何意图.

我有这个测试

  @Test
public void shoulddosomething(){
    startActivity();
    intended(hasComponent(hasClassName(TemplatePictureCaptureActivity.class.getName())));

}
Run Code Online (Sandbox Code Playgroud)

在我的活动中我有这个代码

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(onRequestLayout());
    Intent intent = new Intent(this, TemplatePictureCaptureActivity.class);
    startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)

测试结果是这样的.

android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: Wanted to match 1 intents. Actually matched 0 intents.

IntentMatcher: has component: has component with: class name: is "cat.helm.recertel.ui.templatepicturecapture.TemplatePictureCaptureActivity" package name: an instance of java.lang.String short class name: an instance of java.lang.String

Matched intents:[]

Recorded intents:[]
Run Code Online (Sandbox Code Playgroud)

我试图在onClickListen中启动意图并且它有效,但没有它我无法让它工作.我也尝试过闲置的资源而没有运气.你知道如何实现这个目标吗?

testing android android-intent android-espresso

12
推荐指数
2
解决办法
3302
查看次数