Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created December 10, 2013 09:05
Show Gist options
  • Save timurvafin/7887716 to your computer and use it in GitHub Desktop.
Save timurvafin/7887716 to your computer and use it in GitHub Desktop.
@RunWith(RobolectricGradleTestRunner.class)
public class MainActivityTest {
@Inject CookieManager cookieManager;
@Before
public void setUp() {
injectMocks(this);
}
// tests if the same instance is injected in test and in Activity
@Test
public void testInjection() throws Exception {
assertEquals(cookieManager,
buildActivity(MainActivity.class).create().get().cookieManager);
}
// tests if Activity is finishing if there's no cookie for vk.com
@Test
public void testLoggedOut() throws Exception {
when(cookieManager.getCookie("vk.com")).thenReturn(null);
assertTrue(buildActivity(MainActivity.class).create().get().isFinishing());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment