@Test public void shouldReturnRows() throws IOException { List<String> jsonReports = new ArrayList<String>(); jsonReports.add(getAbsolutePathFromResource("net/masterthought/cucumber/cells.json")); ReportParser reportParser = new ReportParser(jsonReports); Feature feature = reportParser.getFeatures().entrySet().iterator().next().getValue().get(0); Step step = feature.getElements().get(0).getSteps().get(0); feature.processSteps(); assertThat(step.getRows()[0], is(Row.class)); }
@Test public void shouldReturnRowsWhenNoResultsForStep() throws IOException { List<String> jsonReports = new ArrayList<String>(); jsonReports.add( getAbsolutePathFromResource("net/masterthought/cucumber/with_no_step_results.json")); ReportParser reportParser = new ReportParser(jsonReports); Feature feature = reportParser.getFeatures().entrySet().iterator().next().getValue().get(0); Step step = feature.getElements().get(0).getSteps().get(0); feature.processSteps(); assertThat( step.getName(), is( "<div class=\"missing\"><span class=\"step-keyword\">Given </span><span class=\"step-name\">a "Big" customer</span><span class=\"step-duration\"></span><div class=\"step-error-message\"><pre class=\"step-error-message-content\"><span class=\"missing\">Result was missing for this step</span></pre></div></div>")); }
@Test public void shouldReturnName() { assertThat( passingStep.getName(), is( "<div class=\"passed\"><span class=\"step-keyword\">Given </span><span class=\"step-name\">I have a new credit card</span><span class=\"step-duration\">107ms</span></div>")); }
@Test public void shouldReturnNameWhenStepSkipped() { ConfigurationOptions.instance().setSkippedFailsBuild(false); assertThat( skippedStep.getName(), is( "<div class=\"skipped\"><span class=\"step-keyword\">And </span><span class=\"step-name\">the card should be returned</span><span class=\"step-duration\">000ms</span></div>")); }
@Test public void shouldFormatDocString() { assertThat( step.getDocString(), is( "<div class=\"passed\">" + "<div class=\"doc-string\">" + "X _ X<br/>" + "O X O<br/>" + "_ O X" + "</div>" + "</div>")); }
@Test public void shouldReturnNameWhenConfigSkippedTurnedOn() { ConfigurationOptions configuration = ConfigurationOptions.instance(); configuration.setSkippedFailsBuild(true); try { assertThat( skippedStep.getName(), is( "<div class=\"skipped\"><span class=\"step-keyword\">And </span><span class=\"step-name\">the card should be returned</span><span class=\"step-duration\">000ms</span></div>")); } finally { // restore the initial state for next tests configuration.setSkippedFailsBuild(false); } }
@Test public void shouldReturnDataTableClass() { assertThat(passingStep.getDataTableClass(), is("passed")); assertThat(failingStep.getDataTableClass(), is("failed")); }
@Test public void shouldReturnDuration() { assertThat(passingStep.getDuration(), is(107447000L)); }
@Test public void shouldReturnStatus() { assertThat(passingStep.getStatus(), is(Status.PASSED)); assertThat(failingStep.getStatus(), is(Status.FAILED)); }
@Test public void shouldReturnOutput() { assertThat(withOutput.getOutput(), is("<div>some other text</div><div>wooops</div>")); }
@Test public void shouldKnowIfHasRows() { assertThat(passingStep.hasRows(), is(false)); }
@Test public void shouldNotCreateLinkToScreenshotWhenOneDoesNotExist() throws IOException { long screenshotTime = new DateTime().getMillis(); DateTimeUtils.setCurrentMillisFixed(screenshotTime); assertThat(failingStep.getImageTags(), is(EMPTY)); }
@Test public void shouldReturnOutput() { assertThat(withOutput.getOutput(), is(new String[] {"some other text", "wooops"})); }