protected Fixture newFixture() { fixture = new Fixture(); fixture.listener = fixtureListener; return fixture; }
protected Fixture newFixture() { fixture = new Fixture(); fixture.listener = fixtureListener; return fixture; }
private boolean run(Reader reader, Writer writer) throws IOException, ParseException { String input = read(reader); Parse tables = new Parse(input); fixture = new Fixture(); fixture.doTables(tables); PrintWriter output = new PrintWriter(writer); tables.print(output); output.flush(); return passed(fixture); }
@Before public void prepare() { SymbolUtil.setSymbol("NULL_SYMBOL", null); SymbolUtil.setSymbol("SYMBOL_X", "X"); parseHelper = new ParseHelper(new Fixture(), String.class); }
@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")))))); }
@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 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 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 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 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"))))); }
private boolean run(Reader reader, Writer writer) throws IOException, ParseException { listener.beforeTest(testPath); String input = read(reader); Parse tables = new Parse(input); fixture = new Fixture(); fixture.doTables(tables); PrintWriter output = new PrintWriter(writer); tables.print(output); output.flush(); boolean passed = passed(fixture); result = new TestResult(); result.setPath(testPath); result.setPassed(passed); result.setRight(fixture.getCounts().right); result.setWrong(fixture.getCounts().wrong); result.setIgnored(fixture.getCounts().ignores); result.setExceptions(fixture.getCounts().exceptions); listener.afterTest(result); return passed; }
@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")); }