title: Espresso Test Failed: Wanted to match 1 intents. Actually matched 0 intents
body: <p>I am trying to test that my SplashActivity correctly launches HomeActivity if the user is logged in.</p>
  
  <p>I have looked at related questions on StackOverflow, this seems to be a common issue, but I just cannot seem to get anything to work.</p>
  
  <p>I have watched the test execute on my device and visually verified that SplashActivity is indeed launching HomeActivity.</p>
  
  <p>HomeActivity expects a plain intent with no data.</p>
  
  <p><strong>Here is the full error:</strong></p>
  
  <pre><code>IntentMatcher: has component: has component with: class name: is "com.shoeboxed.fetch.presentation.ui.activities.HomeActivity" package name: an instance of java.lang.String short class name: an instance of java.lang.String
  </code></pre>
  
  <p><strong>Initial Attempt:</strong></p>
  
  <pre><code>public class SplashActivityTest extends EspressoIntegrationTest {
  
      @Mock
      UserRepository userRepository;
  
      @Rule
      public IntentsTestRule&lt;SplashActivity&gt; activityRule = new IntentsTestRule&lt;&gt;(SplashActivity.class, true, false);
  
      @Test
      public void loggedInUser() {
          User user = Fakes.user();
          when(userRepository.getUser()).thenReturn(user);
          doNothing().when(userRepository).refreshTeam();
  
          activityRule.launchActivity(new Intent());
          intended(hasComponent(HomeActivity.class.getName()));
  
          verify(userRepository, times(1)).getUser();
          verify(userRepository, times(1)).refreshTeam();
      }
  }
  </code></pre>
  
  <p><strong>Second Attempt:</strong>
  (Trying different matching syntax)</p>
  
  <pre><code>public class SplashActivityTest extends EspressoIntegrationTest {
  
      @Mock
      UserRepository userRepository;
  
      @Rule
      public IntentsTestRule&lt;SplashActivity&gt; activityRule = new IntentsTestRule&lt;&gt;(SplashActivity.class, true, false);
  
      @Test
      public void loggedInUser() {
          User user = Fakes.user();
          when(userRepository.getUser()).thenReturn(user);
          doNothing().when(userRepository).refreshTeam();
  
          activityRule.launchActivity(new Intent());
          intended(hasComponent(new ComponentName(getTargetContext(), HomeActivity.class)));
  
          verify(userRepository, times(1)).getUser();
          verify(userRepository, times(1)).refreshTeam();
      }
  }
  </code></pre>
  
  <p><strong>Third Attempt</strong> 
  (Adding an Idling Resource on the destination activity)</p>
  
  <pre><code>public class SplashActivityTest extends EspressoIntegrationTest {
  
      @Mock
      UserRepository userRepository;
  
      @Rule
      public IntentsTestRule&lt;SplashActivity&gt; activityRule = new IntentsTestRule&lt;&gt;(SplashActivity.class, true, false);
  
      @Test
      public void loggedInUser() {
          User user = Fakes.user();
          when(userRepository.getUser()).thenReturn(user);
          doNothing().when(userRepository).refreshTeam();
  
          WaitActivityIsResumedIdlingResource resource = new WaitActivityIsResumedIdlingResource(HomeActivity.class.getName());
          Espresso.registerIdlingResources(resource);
  
          activityRule.launchActivity(new Intent());
          intended(hasComponent(new ComponentName(getTargetContext(), HomeActivity.class)));
  
          verify(userRepository, times(1)).getUser();
          verify(userRepository, times(1)).refreshTeam();
          Espresso.unregisterIdlingResources(resource);
      }
  
  
      private static class WaitActivityIsResumedIdlingResource implements IdlingResource {
          private final ActivityLifecycleMonitor instance;
          private final String activityToWaitClassName;
          private volatile ResourceCallback resourceCallback;
          boolean resumed = false;
          public WaitActivityIsResumedIdlingResource(String activityToWaitClassName) {
              instance = ActivityLifecycleMonitorRegistry.getInstance();
              this.activityToWaitClassName = activityToWaitClassName;
      }
  
      @Override
      public String getName() {
          return this.getClass().getName();
      }
  
      @Override
      public boolean isIdleNow() {
          resumed = isActivityLaunched();
          if(resumed &amp;&amp; resourceCallback != null) {
              resourceCallback.onTransitionToIdle();
          }
  
          return resumed;
      }
  
      private boolean isActivityLaunched() {
          Collection&lt;Activity&gt; activitiesInStage = instance.getActivitiesInStage(Stage.RESUMED);
          for (Activity activity : activitiesInStage) {
              if(activity.getClass().getName().equals(activityToWaitClassName)){
                  return true;
              }
          }
          return false;
      }
  
      @Override
      public void registerIdleTransitionCallback(IdlingResource.ResourceCallback resourceCallback) {
          this.resourceCallback = resourceCallback;
      }
  }
  </code></pre>
  
  <p>Here is my base test. It registers an idling resource on my background processes (clean architecture use cases):</p>
  
  <pre><code>public class EspressoIntegrationTest {
  
      private static IdlingResource idlingThreadPool;
  
      private AppComponent oldComponent = app().appComponent();
  
      @Rule
      public DaggerMockRule&lt;AppComponent&gt; daggerRule = new DaggerMockRule&lt;&gt;(AppComponent.class, new AppModule(app()))
              .set(component -&gt; {
                  oldComponent = app().appComponent();
                  app().setAppComponent(component);
              });
  
      @BeforeClass
      public static void registerResources() {
          idlingThreadPool = getIdlingThreadExecutor();
          Espresso.registerIdlingResources(idlingThreadPool);
      }
  
      @AfterClass
      public static void deregister() {
          Espresso.unregisterIdlingResources(idlingThreadPool);
      }
  
      @After
      public void resetApp() {
          app().setAppComponent(oldComponent);
      }
  
      private static IdlingResource getIdlingThreadExecutor() {
          return (IdlingResource) jobExecutor().getThreadPoolExecutor();
      }
  
      private static JobExecutor jobExecutor() {
          return ((JobExecutor) app().appComponent().threadExecutor());
      }
  
      private static App app() {
          return (App) getInstrumentation().getTargetContext().getApplicationContext();
      }
  }
  </code></pre>