public boolean run() { FileService fileService = new FileService(runStepConfig); ImageService imageService = new ImageService();
@Test public void shouldFindBeforeImages() throws IOException { runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory("src/test/resources") .withScreenshotsDirectory("screenshots") .withReportDirectory("report") .build(); FileService fileService = new FileService(runStepConfig); //when List<String> beforeFiles = fileService.getFilenamesForStep("/", "http://url", BEFORE); //then assertThat(beforeFiles, is(ImmutableList.of("http_url_root_ff3c40c_1001_02002_before.png"))); }
@Test public void shouldFindAfterImages() throws IOException { runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory("src/test/resources") .withScreenshotsDirectory("screenshots") .withReportDirectory("report") .build(); FileService fileService = new FileService(runStepConfig); //when List<String> afterFiles = fileService.getFilenamesForStep("/", "http://url", AFTER); //then assertThat(afterFiles, is(ImmutableList.of("http_url_root_ff3c40c_1001_02002_after.png", "http_url_root_ff3c40c_1001_03003_after.png"))); }
@Test public void shouldBuildRelativePathsForDifferentDirectories() { //given runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory("src/test/resources") .withScreenshotsDirectory("screenshots") .withReportDirectory("report") .build(); FileService fileService = new FileService(runStepConfig); //when String relativePathFromReportDirToScreenshotsDir = fileService.getRelativePathFromReportDirToScreenshotsDir(); //then assertThat(relativePathFromReportDirToScreenshotsDir, is("../screenshots/")); }
@Test public void shouldBuildRelativePathsForSame() { //given runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory("src/test/resources") .withScreenshotsDirectory("rreeppoorrtt") .withReportDirectory("rreeppoorrtt") .build(); FileService fileService = new FileService(runStepConfig); //when String relativePathFromReportDirToScreenshotsDir = fileService.getRelativePathFromReportDirToScreenshotsDir(); //then assertThat(relativePathFromReportDirToScreenshotsDir, is("")); } }
@Before public void setup() throws IOException { initMocks(this); tempDirPath = tempDir.getRoot().getPath(); writeScreenshotTestPath = tempDirPath + "/testdirforlineupwritetest"; runStepConfig = jLineupRunConfigurationBuilder() .withWorkingDirectory(writeScreenshotTestPath) .withScreenshotsDirectory("screenshots") .withReportDirectory("report") .build(); testee = new FileService(runStepConfig); testee.createDirIfNotExists(writeScreenshotTestPath); testee.createDirIfNotExists(writeScreenshotTestPath + "/screenshots"); testee.createDirIfNotExists(writeScreenshotTestPath + "/report"); }