<commit_before>package com.codeborne.selenide.ex;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.impl.ScreenShotLaboratory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import static com.codeborne.selenide.Screenshots.screenshots;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

public class ErrorMessagesTest {

  private static String reportsUrl;

  @BeforeClass
  public static void rememberOldValues() {
    reportsUrl = Configuration.reportsUrl;
  }

  @AfterClass
  public static void restoreOldValues() {
    Configuration.reportsUrl = reportsUrl;
    screenshots = new ScreenShotLaboratory();
  }

  @Test
  public void formatsTimeoutToReadable() {
    assertEquals("\nTimeout: 0 ms.", ErrorMessages.timeout(0));
    assertEquals("\nTimeout: 1 ms.", ErrorMessages.timeout(1));
    assertEquals("\nTimeout: 999 ms.", ErrorMessages.timeout(999));
    assertEquals("\nTimeout: 1 s.", ErrorMessages.timeout(1000));
    assertEquals("\nTimeout: 1.001 s.", ErrorMessages.timeout(1001));
    assertEquals("\nTimeout: 1.500 s.", ErrorMessages.timeout(1500));
    assertEquals("\nTimeout: 4 s.", ErrorMessages.timeout(4000));
  }

  @Test
  public void convertsScreenshotFileNameToCIUrl() {
    Configuration.reportsUrl = "http://ci.mycompany.com/job/666/artifact/";
    String currentDir = System.getProperty("user.dir");
    screenshots = mock(ScreenShotLaboratory.class);
    doReturn(currentDir + "/test-result/12345.png").when(screenshots).takeScreenShot();

    assertEquals("\nScreenshot: http://ci.mycompany.com/job/666/artifact/test-result/12345.png",
        ErrorMessages.screenshot());
  }

  @Test
  public void returnsScreenshotFileName() {
    Configuration.reportsUrl = null;
    String currentDir = System.getProperty("user.dir");
    screenshots = mock(ScreenShotLaboratory.class);
    doReturn(currentDir + "/test-result/12345.png").when(screenshots).takeScreenShot();

    assertEquals("\nScreenshot: file:" + currentDir + "/test-result/12345.png",
        ErrorMessages.screenshot());
  }
}<commit_msg>Fixed test on Windows<commit_after>package com.codeborne.selenide.ex;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.impl.ScreenShotLaboratory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import static com.codeborne.selenide.Screenshots.screenshots;
import static java.io.File.separatorChar;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

public class ErrorMessagesTest {

  private static String reportsUrl;

  @BeforeClass
  public static void rememberOldValues() {
    reportsUrl = Configuration.reportsUrl;
  }

  @AfterClass
  public static void restoreOldValues() {
    Configuration.reportsUrl = reportsUrl;
    screenshots = new ScreenShotLaboratory();
  }

  @Test
  public void formatsTimeoutToReadable() {
    assertEquals("\nTimeout: 0 ms.", ErrorMessages.timeout(0));
    assertEquals("\nTimeout: 1 ms.", ErrorMessages.timeout(1));
    assertEquals("\nTimeout: 999 ms.", ErrorMessages.timeout(999));
    assertEquals("\nTimeout: 1 s.", ErrorMessages.timeout(1000));
    assertEquals("\nTimeout: 1.001 s.", ErrorMessages.timeout(1001));
    assertEquals("\nTimeout: 1.500 s.", ErrorMessages.timeout(1500));
    assertEquals("\nTimeout: 4 s.", ErrorMessages.timeout(4000));
  }

  @Test
  public void convertsScreenshotFileNameToCIUrl() {
    Configuration.reportsUrl = "http://ci.mycompany.com/job/666/artifact/";
    String currentDir = System.getProperty("user.dir");
    screenshots = mock(ScreenShotLaboratory.class);
    doReturn(currentDir + "/test-result/12345.png").when(screenshots).takeScreenShot();

    assertEquals("\nScreenshot: http://ci.mycompany.com/job/666/artifact/test-result/12345.png",
        ErrorMessages.screenshot());
  }

  @Test
  public void returnsScreenshotFileName() {
    Configuration.reportsUrl = null;
    String currentDir = System.getProperty("user.dir");
    if (separatorChar == '\\') {
      currentDir = '/' + currentDir.replace('\\', '/');
    }

    screenshots = mock(ScreenShotLaboratory.class);
    doReturn(currentDir + "/test-result/12345.png").when(screenshots).takeScreenShot();

    assertEquals("\nScreenshot: file:" + currentDir + "/test-result/12345.png",
        ErrorMessages.screenshot());
  }
}
{'fraction_non_alphanumeric': 0.1334670231729055, 'fraction_numerical': 0.027629233511586453, 'mean_word_length': 4.61125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216320', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1305, 'n_words': 238}