Beispiel #1
0
  @Test
  public void allTestingCompleteShouldSetTotalRunTime() throws Exception {
    FitNesseContext context = mock(FitNesseContext.class);
    WikiPage page = new WikiPageDummy("name", "content");
    WriterFactory writerFactory = mock(WriterFactory.class);
    XmlFormatter formatter =
        new XmlFormatter(context, page, writerFactory) {
          @Override
          protected void writeResults() {}
        };

    TimeMeasurement totalTimeMeasurement = mock(TimeMeasurement.class);
    when(totalTimeMeasurement.elapsed()).thenReturn(77L);
    formatter.allTestingComplete(totalTimeMeasurement);
    assertThat(formatter.testResponse.getTotalRunTimeInMillis(), is(77L));
  }
Beispiel #2
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"));
  }