Created
June 1, 2018 18:10
-
-
Save CollectiveHealth-gists/0de90c8c14b05f632b2879452fe57ee2 to your computer and use it in GitHub Desktop.
ComputerTest implemented using TestModule.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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