/** tear down test fixture */
  @After
  public void tearDown() {
    // assert all downloads done after wait
    boolean allDownloadJobsDone = parallelDownloadService.waitTillAllDownloadJobsDone();

    if (!ConfigHolder.getInstance().isContinueOnError()) assertTrue(allDownloadJobsDone);
    // else isContinueOnError, so acceptable if not all jobs done due to errors

    // reset
    setContinueOnError(false);
  }
  // random test (simulates random network errors for comprehensive test coverage of scenarios)
  @Test
  public void continuesOnRandomNetworkErrorsIfConfigured() throws Exception {
    printTestHeader("continuesOnExceptions");

    ConfigHolder.getInstance().setContinueOnError(true);
    ProgressWatcher.getInstance().setLogErrorsToFile(true);

    SmartsheetBackupService backupService =
        new SmartsheetBackupService(
            new ErrorContextualizingSmartsheetService(new StubBadConnectionSmartsheetService()),
            parallelDownloadService);

    backupToTempDir(backupService);

    if (ProgressWatcher.getInstance().getErrorCount() > 0) {
      String errorLogFile = ProgressWatcher.getInstance().getErrorLogFile();
      assertNotNull(errorLogFile);
      printErrorLogFilePathWhenDone(errorLogFile);
    }
  }
 private static void setContinueOnError(boolean continueOnError) {
   ConfigHolder.getInstance().setContinueOnError(continueOnError);
   // the backup tool does setLogErrorsToFile true if continueOnError is true,
   // so simulate that behaviour by having the test do the same here:
   ProgressWatcher.getInstance().setLogErrorsToFile(continueOnError);
 }