@Override public String lookup(String name) { try { Object value = evaluator.evaluate(name); if (value == null) { return ""; } else { return value.toString(); } } catch (Exception e) { resultRecorder.record(Result.FAILURE); return "<span class=\"failure\">" + e.toString() + "</span>"; } } }, "$(", ")", '\\');
public void call(Runner runner, Resource resource, String href, ResultAnnouncer announcer, ResultRecorder resultRecorder) { try { ResultSummary result = runner.execute(resource, href); announcer.announce(result); resultRecorder.record(result); } catch (FailFastException e) { announcer.announceException(e); resultRecorder.record(Result.EXCEPTION); // we let fail fast exceptions percolate up through the system throw e; } catch (Throwable e) { announcer.announceException(e); resultRecorder.record(Result.EXCEPTION); } } }
public void call(Runner runner, Resource resource, String href, ResultAnnouncer announcer, ResultRecorder resultRecorder) { try { ResultSummary result = runner.execute(resource, href); announcer.announce(result); resultRecorder.record(result); } catch (FailFastException e) { announcer.announceException(e); resultRecorder.record(Result.EXCEPTION); // we let fail fast exceptions percolate up through the system throw e; } catch (Throwable e) { announcer.announceException(e); resultRecorder.record(Result.EXCEPTION); } } }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); } }
@Override protected void processFalseResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); }
@Override protected void processFalseResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.SUCCESS); announceSuccess(commandCall.getElement()); } }
@Override public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { Check.isFalse(commandCall.hasChildCommands(), "Nesting commands inside an 'assertEquals' is not supported"); Element element = commandCall.getElement(); Object actual = evaluator.evaluate(commandCall.getExpression()); String expected = element.getText(); if (comparator.compare(actual, expected) == 0) { resultRecorder.record(Result.SUCCESS); announceSuccess(element); } else { resultRecorder.record(Result.FAILURE); announceFailure(element, expected, actual); } }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.FAILURE); String expected = commandCall.getElement().getText(); announceFailure(commandCall.getElement(), expected, "== true"); }
@Override public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { Check.isFalse(commandCall.hasChildCommands(), "Nesting commands inside an 'assertEquals' is not supported"); Element element = commandCall.getElement(); Object actual = evaluator.evaluate(commandCall.getExpression()); String expected = element.getText(); if (comparator.compare(actual, expected) == 0) { resultRecorder.record(Result.SUCCESS); announceSuccess(element); } else { resultRecorder.record(Result.FAILURE); announceFailure(element, expected, actual); } }
@Override protected void processFalseResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.FAILURE); String expected = commandCall.getElement().getText(); announceFailure(commandCall.getElement(), expected, "== false"); }
@Override protected void processTrueResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.FAILURE); String expected = commandCall.getElement().getText(); announceFailure(commandCall.getElement(), expected, "== true"); }
@Override protected void processFalseResult(CommandCall commandCall, ResultRecorder resultRecorder) { resultRecorder.record(Result.FAILURE); String expected = commandCall.getElement().getText(); announceFailure(commandCall.getElement(), expected, "== false"); }
@Override protected void process(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Runnable runnable) { try { runnable.run(); } catch (FailFastException ffe) { // We get here if a sub-fixture has thrown an exception and we want the fail fast exception to percolate up. rethrowFailFastException(resultRecorder, ffe.getCause()); } catch (Throwable t) { resultRecorder.record(Result.EXCEPTION); announceThrowableCaught(commandCall.getElement(), t, commandCall.getExpression()); rethrowFailFastException(resultRecorder, t); } }
@Override protected void process(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Runnable runnable) { try { runnable.run(); } catch (FailFastException ffe) { // We get here if a sub-fixture has thrown an exception and we want the fail fast exception to percolate up. rethrowFailFastException(resultRecorder, ffe.getCause()); } catch (Throwable t) { resultRecorder.record(Result.EXCEPTION); announceThrowableCaught(commandCall.getElement(), t, commandCall.getExpression()); rethrowFailFastException(resultRecorder, t); } }
@Override public void verify(Fixture fixture) { announceExpressionEvaluated(commandCall.getElement()); int index = 0; for (Object loopVar : actualRows) { evaluator.setVariable(loopVariableName, loopVar); Row detailRow; if (expectedRows.length > index) { detailRow = expectedRows[index]; } else { detailRow = tableSupport.addDetailRow(); announceSurplusRow(detailRow.getElement()); } tableSupport.copyCommandCallsTo(detailRow); commandCall.getChildren().verify(evaluator, resultRecorder, fixture); index++; } for (; index < expectedRows.length; index++) { Row detailRow = expectedRows[index]; resultRecorder.record(Result.FAILURE); announceMissingRow(detailRow.getElement()); } } }
@Override public void verify(Fixture fixture) { announceExpressionEvaluated(commandCall.getElement()); int index = 0; for (Object loopVar : actualRows) { evaluator.setVariable(loopVariableName, loopVar); Row detailRow; if (expectedRows.length > index) { detailRow = expectedRows[index]; } else { detailRow = tableSupport.addDetailRow(); announceSurplusRow(detailRow.getElement()); } tableSupport.copyCommandCallsTo(detailRow); commandCall.getChildren().verify(evaluator, resultRecorder, fixture); index++; } for (; index < expectedRows.length; index++) { Row detailRow = expectedRows[index]; resultRecorder.record(Result.FAILURE); announceMissingRow(detailRow.getElement()); } } }
public void execute(CommandCall node, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { String exampleName = getExampleName(node); boolean isBeforeExample = isBeforeExample(node); resultRecorder.setSpecificationDescription( specificationDescriber.getDescription(node.getResource(), exampleName)); ImplementationStatus status = getImplementationStatus(node); if (!isBeforeExample && status != ImplementationStatus.IGNORED) { announceBeforeExample(exampleName, node.getElement(), resultRecorder, fixture); } try { resultRecorder.setImplementationStatus(status); if (status == ImplementationStatus.IGNORED) { resultRecorder.record(Result.IGNORED); } else { node.getChildren().processSequentially(evaluator, resultRecorder, fixture); } } catch (FailFastException f) { // Ignore - it'll be re-thrown later by the implementation status checker if necessary. } setupCommandForExample(node, resultRecorder, exampleName); if (!isBeforeExample && status != ImplementationStatus.IGNORED) { announceAfterExample(exampleName, node.getElement(), resultRecorder, fixture); } }
public void execute(CommandCall node, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) { String exampleName = getExampleName(node); boolean isBeforeExample = isBeforeExample(node); resultRecorder.setSpecificationDescription( specificationDescriber.getDescription(node.getResource(), exampleName)); ImplementationStatus status = getImplementationStatus(node); if (!isBeforeExample && status != ImplementationStatus.IGNORED) { announceBeforeExample(exampleName, node.getElement(), resultRecorder, fixture); } try { resultRecorder.setImplementationStatus(status); if (status == ImplementationStatus.IGNORED) { resultRecorder.record(Result.IGNORED); } else { node.getChildren().processSequentially(evaluator, resultRecorder, fixture); } } catch (FailFastException f) { // Ignore - it'll be re-thrown later by the implementation status checker if necessary. } setupCommandForExample(node, resultRecorder, exampleName); if (!isBeforeExample && status != ImplementationStatus.IGNORED) { announceAfterExample(exampleName, node.getElement(), resultRecorder, fixture); } }