Created
December 8, 2020 16:00
-
-
Save sjabiulla/4a557516e834bba6d6047687f7e32deb to your computer and use it in GitHub Desktop.
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
import static org.junit.Assert.fail; | |
import static org.mockito.Matchers.anyString; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.powermock.api.mockito.PowerMockito; | |
import org.powermock.core.classloader.annotations.PrepareForTest; | |
import org.powermock.modules.junit4.PowerMockRunner; | |
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(Tournament.class) | |
public class TournamentTest { | |
@Test | |
public void testTournament() { | |
try { | |
Tournament mock = PowerMockito.mock(Tournament.class); | |
PowerMockito.when(mock.isAlreadyRegistered(anyString())).thenReturn(true); | |
PowerMockito.whenNew(Tournament.class).withAnyArguments().thenReturn(mock); | |
Tournament.main(null); | |
} catch (Exception e) { | |
fail(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment