Skip to content

Instantly share code, notes, and snippets.

@dlemures
Created May 17, 2016 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlemures/3c5993b67c3dc066afc8729df4484b5e to your computer and use it in GitHub Desktop.
Save dlemures/3c5993b67c3dc066afc8729df4484b5e to your computer and use it in GitHub Desktop.
public class SmoothieMakerTest {
@Rule public EasyMockRule mocks = new EasyMockRule(this);
@TestSubject private SmoothieMaker smoothieMakerUnderTest = new SmoothieMaker();
@Mock private Blender mockBlender;
@Mock private Freezer mockFreezer;
@After
public void tearDown() throws Exception {
ToothPick.reset();
}
@Test
public void testMakeSmoothie() throws Exception {
//GIVEN
mockBlender.mix();
mockFreezer.freeze();
replay(mockBlender, mockFreezer);
Scope scope = ToothPick.openScope("TestScope");
scope.installTestModules(new TestModule());
//WHEN
smoothieMakerUnderTest.makeSmoothie();
//THEN
verify(mockBlender, mockFreezer);
}
private class TestModule extends Module {
public TestModule() {
bind(Blender.class).to(mockBlender);
bind(Freezer.class).to(mockFreezer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment