Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CollectiveHealth-gists/0de90c8c14b05f632b2879452fe57ee2 to your computer and use it in GitHub Desktop.
Save CollectiveHealth-gists/0de90c8c14b05f632b2879452fe57ee2 to your computer and use it in GitHub Desktop.
ComputerTest implemented using TestModule.
public class ComputerTestUsingTestModule {
@Test
public void testPlayVideo() {
Injector injector = Guice.createInjector(new TestModule()
.withMockedClasses(SoundSystem.class, DisplaySystem.class));
Computer computer = injector.getInstance(Computer.class);
SoundSystem soundSystem = injector.getInstance(SoundSystem.class);
DisplaySystem displaySystem = injector.getInstance(DisplaySystem.class);
computer.playVideo();
Mockito.verify(soundSystem).playAudio(Mockito.any());
Mockito.verify(displaySystem).playVideo(Mockito.any());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment