小编Var*_*run的帖子

Espresso 测试失败:AssertionFailedWithCause:想要匹配 1 个意图。实际匹配 0 个意图

我是 Android Instrumentation 测试的新手。我想检查我的注册活动是否与 Espresso 正常工作。

我也尝试过有意图地运行它。似乎不起作用。

以下是我的代码:

package com.varun.project;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertEquals;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

    @Rule
    public IntentsTestRule<Register> ResgisterTestRule =
            new IntentsTestRule<>(Register.class, true, true);

    @Test …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-testing android-espresso

5
推荐指数
1
解决办法
2491
查看次数