public void setScopeName(Object scopeName) { if (scope != null) { throw new IllegalStateException("scope is already initialized, use a constructor without a scope name for the rule."); } scope = Toothpick.openScope(scopeName); scope.installTestModules(testModule); }
@Test public void testMultiply() throws Exception { //GIVEN expect(mockComputer.compute()).andReturn(4); expect(mockComputer2.compute()).andReturn(4); replay(mockComputer, mockComputer2); final Scope scope = Toothpick.openScope("SimpleEntryPoint"); scope.installTestModules(new TestModule()); //WHEN int result = simpleEntryPointUnderTest.multiply(); //THEN assertThat(result, is(48)); verify(mockComputer); }
public void setScopeName(Object scopeName) { if (scope != null) { throw new IllegalStateException("scope is already initialized, use a constructor without a scope name for the rule."); } scope = ToothPick.openScope(scopeName); scope.installTestModules(testModule); }
@Test public void testWithContextNamerTestModuleWithMock() { ContextNamer contextNamer = createMock(ContextNamer.class); expect(contextNamer.getApplicationName()).andReturn("TestAppNameMock"); expect(contextNamer.getActivityName()).andReturn("TestActivityNameMock"); replay(contextNamer); appScope.installTestModules(new ContextNamerTestModule(contextNamer)); activityRule.launchActivity(null); verify(contextNamer); onView(withId(R.id.title)) .check(matches(withText("TestAppNameMock"))); onView(withId(R.id.subtitle)) .check(matches(withText("TestActivityNameMock"))); }
@Test public void testWithContextNamerTestModule() { appScope.installTestModules(new ContextNamerTestModule(new TestContextNamer("TestAppName", "TestActivityName"))); activityRule.launchActivity(null); onView(withId(R.id.title)) .check(matches(withText("TestAppName"))); onView(withId(R.id.subtitle)) .check(matches(withText("TestActivityName"))); }