Exemplo n.º 1
0
  @Test
  public void processTestResultsShouldBuildUpCurrentResultAndFinalSummary() throws Exception {
    FitNesseContext context = mock(FitNesseContext.class);
    TestPage page = new TestPage(new WikiPageDummy("name", "content"));
    page.getData().setAttribute(PageData.PropertySUITES, "tag1");
    WriterFactory writerFactory = mock(WriterFactory.class);
    final TestResult testResult = new TestResult();
    XmlFormatter formatter =
        new XmlFormatter(context, page.getSourcePage(), writerFactory) {
          @Override
          protected TestResult newTestResult() {
            return testResult;
          }
        };

    formatter.testOutputChunk("outputChunk");

    TimeMeasurement timeMeasurement =
        new TimeMeasurement() {
          public long elapsed() {
            return 27;
          }
        }.start();
    formatter.newTestStarted(page, timeMeasurement);

    TestSummary summary = new TestSummary(9, 8, 7, 6);
    formatter.testComplete(page, summary, timeMeasurement);
    assertThat(formatter.finalSummary, equalTo(summary));
    assertThat(formatter.testResponse.results.size(), is(1));
    assertThat(formatter.testResponse.results.get(0), is(testResult));
    assertThat(testResult.startTime, is(timeMeasurement.startedAt()));
    assertThat(testResult.content, is("outputChunk"));
    assertThat(testResult.right, is("9"));
    assertThat(testResult.wrong, is("8"));
    assertThat(testResult.ignores, is("7"));
    assertThat(testResult.exceptions, is("6"));
    assertThat(testResult.runTimeInMillis, is("27"));
    assertThat(testResult.relativePageName, is(page.getName()));
    assertThat(testResult.tags, is("tag1"));
  }