コード例 #1
0
  @Test
  public void testForwardingOneOrMoreFails() throws Exception {
    final int state[] = new int[] {0};
    AbstractSuitePresenter presenter =
        new AbstractSuitePresenter() {
          public void displayOneOrMoreFailure(KoanSuiteResult result) {
            assertEquals(0, state[0]);
            state[0] = 1;
          }

          public void displayChart(KoanSuiteResult result) {
            assertEquals(1, state[0]);
            state[0] = 2;
          }

          public void displayPassingFailing(KoanSuiteResult result) {
            assertEquals(2, state[0]);
            state[0] = 3;
          }

          public void displayHeader(KoanSuiteResult result) {
            assertEquals(3, state[0]);
            state[0] = 4;
          }

          public void displayAllSuccess(KoanSuiteResult result) {
            fail();
          }
        };

    KoanSuiteResult kr = new KoanResultBuilder().failingCase(OneFailingKoan.class).build();
    presenter.displayResult(kr);
    assertEquals(4, state[0]);
  }
コード例 #2
0
  @Test
  public void testForwardingOneOrMoreFails() throws Exception {
    final int state[] = new int[] {0};
    AbstractSuitePresenter presenter =
        new AbstractSuitePresenter() {
          public void displayOneOrMoreFailure(KoanSuiteResult result) {
            assertEquals(0, state[0]);
            state[0] = 1;
          }

          public void displayChart(KoanSuiteResult result) {
            assertEquals(1, state[0]);
            state[0] = 2;
          }

          public void displayPassingFailing(KoanSuiteResult result) {
            assertEquals(2, state[0]);
            state[0] = 3;
          }

          public void displayHeader(KoanSuiteResult result) {
            assertEquals(3, state[0]);
            state[0] = 4;
          }

          public void displayAllSuccess(KoanSuiteResult result) {
            fail();
          }

          public void displayError(String error) {
            fail();
          }

          public void displayMessage(String error) {
            fail();
          }
        };

    KoanSuiteResult kr =
        new KoanResultBuilder()
            .remainingCases(Arrays.asList(OneFailingKoan.class.getSimpleName()))
            .methodResult(
                new KoanMethodResult(
                    KoanMethod.getInstance("", OneFailingKoan.class.getDeclaredMethods()[0]),
                    "",
                    ""))
            .build();
    presenter.displayResult(kr);
    assertEquals(4, state[0]);
  }