Skip to content

Instantly share code, notes, and snippets.

@sjabiulla
Created December 8, 2020 16:00
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 sjabiulla/4a557516e834bba6d6047687f7e32deb to your computer and use it in GitHub Desktop.
Save sjabiulla/4a557516e834bba6d6047687f7e32deb to your computer and use it in GitHub Desktop.
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