@Test public void should_generate_an_HTML_report_for_an_acceptance_test_run() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); File htmlReport = reporter.generateReportFor(testOutcome, allTestOutcomes); assertThat(htmlReport.exists(), is(true)); }
@Test public void css_stylesheets_should_also_be_copied_to_the_output_directory() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); reporter.generateReportFor(testOutcome, allTestOutcomes); File cssDir = new File(outputDirectory, "css"); File cssStylesheet = new File(cssDir, "core.css"); assertThat(cssStylesheet.exists(), is(true)); }
@Test public void should_generate_an_HTML_report_for_an_acceptance_test_run_with_issue_numbers_in_the_test_name() throws Exception { TestOutcome testOutcome = new TestOutcome("A simple test case (#ISSUE-123, #ISSUE-145)"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); File htmlReport = reporter.generateReportFor(testOutcome, allTestOutcomes); assertThat(htmlReport.getName(), is(Digest.ofTextValue("a_simple_test_case") + ".html")); }
@Test public void a_different_resource_location_can_be_specified_by_using_a_system_property() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); environmentVariables.setProperty("thucydides.report.resources", "alt-report-resources"); reporter.generateReportFor(testOutcome, allTestOutcomes); File expectedCssStylesheet = new File(new File(outputDirectory, "css"), "alternative.css"); assertThat(expectedCssStylesheet.exists(), is(true)); }
@Test public void the_resources_can_come_from_the_current_project() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); final String alternativeResourceDirectory = "localresourcelist"; reporter.setResourceDirectory(alternativeResourceDirectory); reporter.generateReportFor(testOutcome, allTestOutcomes); File expectedCssStylesheet = new File(new File(outputDirectory, "css"), "localsample.css"); assertThat(expectedCssStylesheet.exists(), is(true)); }
@Test public void when_an_alternative_resource_directory_is_used_the_default_stylesheet_is_not_copied() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); final String alternativeResourceDirectory = "alt-report-resources"; reporter.setResourceDirectory(alternativeResourceDirectory); reporter.generateReportFor(testOutcome, allTestOutcomes); File defaultCssStylesheet = new File(new File(outputDirectory, "css"), "core.css"); assertThat(defaultCssStylesheet.exists(), is(false)); }
@Test public void should_have_a_meaningful_filename() throws Exception { TestOutcome testOutcome = TestOutcome.forTest("should_do_this", SomeTestScenario.class); TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1"); File screenshot = temporaryDirectory.newFile("google_page_1.png"); File screenshotSource = temporaryDirectory.newFile("google_page_1.html"); step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, screenshotSource)); testOutcome.recordStep(step1); File xmlReport = reporter.generateReportFor(testOutcome, allTestOutcomes); assertThat( xmlReport.getName(), is(Digest.ofTextValue("a_user_story_should_do_this") + ".html")); }
@Test public void the_report_file_and_the_resources_should_be_together() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); reporter.generateReportFor(testOutcome, allTestOutcomes); File report = new File(outputDirectory, Digest.ofTextValue("a_simple_test_case") + ".html"); File cssDir = new File(outputDirectory, "css"); File cssStylesheet = new File(cssDir, "core.css"); assertThat(cssStylesheet.exists(), is(true)); assertThat(report.exists(), is(true)); }
@Test public void css_stylesheets_should_be_copied_to_a_non_standard_output_directory() throws Exception { File differentOutputDirectory = new File(temporaryFolder.newFolder(), "build/thucydides"); reporter.setOutputDirectory(differentOutputDirectory); TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); reporter.generateReportFor(testOutcome, allTestOutcomes); File cssDir = new File(differentOutputDirectory, "css"); File cssStylesheet = new File(cssDir, "core.css"); assertThat(cssStylesheet.exists(), is(true)); }
@Test public void spaces_in_the_qualifier_are_converted_to_underscores_for_the_report_name() throws Exception { TestOutcome testOutcome = TestOutcome.forTest("should_do_this", SomeTestScenario.class); TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1"); File screenshot = temporaryDirectory.newFile("google_page_1.png"); File screenshotSource = temporaryDirectory.newFile("google_page_1.html"); step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, screenshotSource)); testOutcome.recordStep(step1); reporter.setQualifier("a b c"); File xmlReport = reporter.generateReportFor(testOutcome, allTestOutcomes); assertThat( xmlReport.getName(), is(Digest.ofTextValue("a_user_story_should_do_this_a_b_c") + ".html")); }
@Test public void screenshots_should_have_a_separate_html_report() throws Exception { TestOutcome testOutcome = TestOutcome.forTest("should_do_this", SomeTestScenario.class); TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1"); File screenshot = temporaryDirectory.newFile("google_page_1.png"); File screenshotSource = temporaryDirectory.newFile("google_page_1.html"); step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, screenshotSource)); testOutcome.recordStep(step1); reporter.generateReportFor(testOutcome, allTestOutcomes); File screenshotReport = new File( outputDirectory, Digest.ofTextValue("a_user_story_should_do_this") + "_screenshots.html"); assertThat(screenshotReport.exists(), is(true)); }
@Test public void screenshot_html_should_mention_the_step_name() throws Exception { TestOutcome testOutcome = TestOutcome.forTest("should_do_this", SomeTestScenario.class); TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1"); File screenshot = temporaryDirectory.newFile("google_page_1.png"); File screenshotSource = temporaryDirectory.newFile("google_page_1.html"); step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, screenshotSource)); testOutcome.recordStep(step1); reporter.generateReportFor(testOutcome, allTestOutcomes); File screenshotReport = new File( outputDirectory, Digest.ofTextValue("a_user_story_should_do_this") + "_screenshots.html"); String reportContents = FileUtils.readFileToString(screenshotReport); assertThat(reportContents, containsString("step 1")); }
@Test public void a_sample_report_should_be_generated_in_the_target_directory() throws Exception { TestOutcome testOutcome = new TestOutcome("a_simple_test_case"); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1")); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 2")); testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 3")); testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 4")); testOutcome.recordStep(TestStepFactory.skippedTestStepCalled("step 5")); testOutcome.recordStep(TestStepFactory.pendingTestStepCalled("step 6")); reporter.setOutputDirectory(new File("target/thucyidides")); reporter.generateReportFor(testOutcome, allTestOutcomes); }