コード例 #1
0
  @Test
  public void shouldBeAbleToCallQuitBrowserMultipleTimes() throws Exception {
    ChromeDriver mockChromeDriver = mock(ChromeDriver.class);
    ChromeDriverService mockService = mock(ChromeDriverService.class);
    when(mockService.isRunning()).thenReturn(true);
    config.getServices().put(config.currentThreadName(), mockService);

    config.quitBrowser(mockChromeDriver);
    config.quitBrowser(mockChromeDriver);

    assertThat(config.getServices(), is(Collections.<String, ChromeDriverService>emptyMap()));
    verify(mockService, times(1)).stop();
  }
コード例 #2
0
  @Test
  public void shouldNotStopServiceIfNotRunningWhenQuitBrowserIsInvoked() throws Exception {
    ChromeDriver mockChromeDriver = mock(ChromeDriver.class);
    ChromeDriverService mockService = mock(ChromeDriverService.class);
    when(mockService.isRunning()).thenReturn(false);
    config.getServices().put(config.currentThreadName(), mockService);

    config.quitBrowser(mockChromeDriver);

    verify(mockChromeDriver).quit();
    assertThat(config.getServices(), is(Collections.<String, ChromeDriverService>emptyMap()));
    verify(mockService, times(0)).stop();
  }