@Test
  public void shouldReportMissingRows() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addCell(createCellResult("*S-1*", null, SUCCESS));
    reportingSystem.addCell(createCellResult("*S-2*", null, SUCCESS));
    reportingSystem.endRow(createNullRowResult(SUCCESS));

    reportingSystem.addCell(createCellResult("*M-1*", null, MISSING));
    reportingSystem.addCell(createCellResult("*M-2*", null, MISSING));
    reportingSystem.endRow(createNullRowResult(MISSING));

    assertThat(table, numRowsWithDescription(1, "missing", "fail"));
  }
  @Test
  public void shouldCallFixtureRightOnCellRight() {
    reportingSystem.addCell(createCellResult("*cell-demo-1*", SUCCESS));

    verify(fixture).right(captor.capture());
    assertThat(captor.getValue().body, hasToString("*cell-demo-1*"));
  }
  @Test
  public void shouldAddCellWithClassFailToOutput() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addCell(createCellResult("*GOOD-1*", "*BAD-2*", WRONG));

    assertThat(table, numCellsWith(1, "*GOOD-1*", "fail"));
  }
  @Test
  public void shouldAddCellWithClassPassToOutput() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addCell(createCellResult("*cell-demo-1*", SUCCESS));

    assertThat(table, numCellsWith(1, "*cell-demo-1*", "pass"));
  }
  @Test
  public void testAddExceptionWhileInTheMiddleOfRow() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);
    reportingSystem.addCell(createCellResult("*S-1*", SUCCESS));

    reportingSystem.addException(new Exception("Cruel World!"));

    assertThat(
        table,
        isParseThat()
            .withRecursiveChildren()
            .withRecursiveSiblings()
            .which(
                allOf(
                    hasTagThat(containsString("<td")),
                    hasBodyThat(
                        allOf(containsString("Cruel World!"), containsString("stacktrace"))))));
  }
  @Test
  public void shouldReportExceptionCells() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addCell(createCellException("*E-1*", "*E-1*", new Exception("Cruel World!")));
    reportingSystem.endRow(createNullRowResult(EXCEPTION));

    assertThat(table, numCellsWith(1, "*E-1*", "error"));
    assertThat(
        table,
        isParseThat()
            .withRecursiveChildren()
            .withRecursiveSiblings()
            .which(
                allOf(
                    hasTagThat(containsString("<td")),
                    hasBodyThat(containsString("Cruel World!")),
                    hasBodyThat(containsString("stacktrace")))));
  }
  @Test
  public void shouldReportSurplusRows() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addCell(createCellResult("*M-1*", null, MISSING));
    reportingSystem.endRow(createNullRowResult(MISSING));
    reportingSystem.addCell(createCellResult(null, "*S-1*", SURPLUS));
    reportingSystem.endRow(createNullRowResult(SURPLUS));

    assertThat(
        table,
        numPartsThat(
            1,
            allOf(
                hasTagThat(allOf(containsString("<tr"), containsString("fail"))),
                hasDescriptionThat(containsString("surplus")),
                numPartsThat(
                    1,
                    allOf(
                        hasTagThat(allOf(containsString("<td"), containsString("fail"))),
                        hasBodyThat(containsString("*S-1*")))))));
  }
  @Test
  public void testAddExceptionOnStart() {
    reportingSystem = new FitFixtureReportingSystem(new Fixture(), table);

    reportingSystem.addException(new Exception("Cruel World!"));

    assertThat(
        table,
        isParseThat()
            .withRecursiveChildren()
            .withRecursiveSiblings()
            .which(
                allOf(
                    hasTagThat(containsString("<td")),
                    hasBodyThat(
                        allOf(containsString("Cruel World!"), containsString("stacktrace"))))));
  }
 private void addCell(String text, MatchStatus status) {
   reportingSystem.addCell(createCellResult(text, status));
 }