You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Sample Code

Mocking a URL


URLConnection mockURLConnection = mock(HttpsURLConnection.class);
URL mockUrl = mock(URL.class);
when(new URL(anyString())).thenReturn(mockUrl);
when(mockUrl.openConnection()).thenReturn(mockURLConnection);


  • No labels