@Test public void the_first_screenshot_can_be_used_to_represent_the_step() throws IOException { TestStep step = new TestStep("a narrative description"); File screenshot = temporaryFolder.newFile("screenshot.png"); File source = temporaryFolder.newFile("screenshot.html"); step.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source)); File screenshot2 = temporaryFolder.newFile("screenshot2.png"); File source2 = temporaryFolder.newFile("screenshot2.html"); step.addScreenshot(new ScreenshotAndHtmlSource(screenshot2, source2)); assertThat(step.getFirstScreenshot().getScreenshot(), is(screenshot)); assertThat(step.getFirstScreenshot().getHtmlSource().get(), is(source)); }
@Test public void the_test_step_knows_how_many_illustrations_it_has() throws IOException { TestStep step = new TestStep("a narrative description"); step.addScreenshot( forScreenshotWithImage("/screenshots/google_page_1.png") .and() .withSource("screenshot.html")); step.addScreenshot( forScreenshotWithImage("/screenshots/google_page_2.png") .and() .withSource("screenshot2.html")); step.addScreenshot( forScreenshotWithImage("/screenshots/google_page_3.png") .and() .withSource("screenshot2.html")); assertThat(step.getScreenshotCount(), is(3)); }
@Test public void if_a_screenshot_is_identical_to_the_previous_one_in_the_step_it_wont_be_added() throws IOException { TestStep step = new TestStep("a narrative description"); File screenshot = temporaryFolder.newFile("screenshot.png"); File source = temporaryFolder.newFile("screenshot.html"); step.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source)); step.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source)); assertThat(step.getScreenshots().size(), is(1)); }
@Test public void the_test_step_can_have_more_than_one_illustration() throws IOException { TestStep step = new TestStep("a narrative description"); step.addScreenshot( forScreenshotWithImage("/screenshots/google_page_1.png") .and() .withSource("screenshot.html")); step.addScreenshot( forScreenshotWithImage("/screenshots/google_page_2.png") .and() .withSource("screenshot2.html")); ScreenshotAndHtmlSource screenshot1 = step.getScreenshots().get(0); ScreenshotAndHtmlSource screenshot2 = step.getScreenshots().get(1); assertThat(screenshot1.getScreenshot().getName(), is("google_page_1.png")); assertThat(screenshot1.getHtmlSource().get().getName(), is("screenshot.html")); assertThat(screenshot2.getScreenshot().getName(), is("google_page_2.png")); assertThat(screenshot2.getHtmlSource().get().getName(), is("screenshot2.html")); assertThat(screenshot1.hashCode(), is(not(screenshot2.hashCode()))); }
@Test public void the_test_step_can_have_an_illustration() throws IOException { TestStep step = new TestStep("a narrative description"); File screenshot = temporaryFolder.newFile("screenshot.png"); File source = temporaryFolder.newFile("screenshot.html"); assertThat(step.hasScreenshots(), is(false)); step.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source)); assertThat(step.hasScreenshots(), is(true)); assertThat(step.getScreenshots().get(0).getScreenshot(), is(screenshot)); assertThat(step.getScreenshots().get(0).getHtmlSource().get(), is(source)); }