Code example for MalformedURLException

0
        verifyNew(AndroidDriver.class, times(1)).withArguments(isA(URL.class), isA(DesiredCapabilities.class));
    } 
 
    @Test 
    public void shouldHandleInvalidUrl() throws Exception { 
        whenNew(AndroidDriver.class).withParameterTypes(URL.class, DesiredCapabilities.class).withArguments(isA(URL.class), isA(DesiredCapabilities.class)).thenThrow(new MalformedURLException("testing123"));
 
        final AndroidDriver browser = config.createBrowser();
        assertNull(browser);
    } 
 
    @Test 
    public void shouldCreateWebDriverWhenThreadStartedIsInvoked() throws Exception { 
        AndroidDriver mockAndroidDriver = Mockito.mock(AndroidDriver.class);
        whenNew(AndroidDriver.class).withParameterTypes(URL.class, DesiredCapabilities.class).withArguments(isA(URL.class), isA(DesiredCapabilities.class)).thenReturn(mockAndroidDriver);
 
        config.threadStarted();
 
        assertThat(config.getThreadBrowser(), is(mockAndroidDriver));
        verifyNew(AndroidDriver.class, times(1)).withArguments(isA(URL.class), isA(DesiredCapabilities.class));
    }