public ResultExec convertResult(Result result) { return new ResultExec( result.getStatus(), result.getError(), result.getErrorMessage(), result.getDuration()); }
private void printHookFailure(Match match, Result result, boolean isBefore) { if (result.getStatus().equals(Result.FAILED)) { Format format = getFormat(result.getStatus()); StringBuffer context = new StringBuffer("Failure in "); if (isBefore) { context.append("before"); } else { context.append("after"); } context.append(" hook:"); out.println(format.text(context.toString()) + format.text(match.getLocation())); out.println(format.text("Message: ") + format.text(result.getErrorMessage())); if (result.getError() != null) { printError(result); } } }
public String getResultStatus() { if (result != null) { return result.getStatus(); } return "skipped"; }
@Override public void result( Result result ) { super.result( result ); if( result.getStatus().equals( Result.FAILED ) && BooleanUtils.toBoolean( System.getProperty( PROPERTY_PAUSE_ON_ERROR )) ){ JFrame jf = new JFrame(); JOptionPane.showMessageDialog( jf, result.getErrorMessage(), "Exception occurred!", JOptionPane.INFORMATION_MESSAGE ); jf.toFront(); jf.repaint(); } }
protected void fireFixtureStep(final Match match, final Result result, final boolean isBefore) { final String uuid = md5(match.getLocation()); final StepResult stepResult = new StepResult() .setName(match.getLocation()) .setStatus(Status.fromValue(result.getStatus())) .setStart(System.currentTimeMillis() - result.getDuration()) .setStop(System.currentTimeMillis()); if (FAILED.equals(result.getStatus())) { final StatusDetails statusDetails = ResultsUtils.getStatusDetails(result.getError()).get(); stepResult.setStatusDetails(statusDetails); if (isBefore) { final TagParser tagParser = new TagParser(feature, scenario); statusDetails .setMessage("Before is failed: " + result.getError().getLocalizedMessage()) .setFlaky(tagParser.isFlaky()) .setMuted(tagParser.isMuted()) .setKnown(tagParser.isKnown()); lifecycle.updateTestCase(scenario.getId(), scenarioResult -> scenarioResult.setStatus(Status.SKIPPED) .setStatusDetails(statusDetails)); } } lifecycle.startStep(scenario.getId(), uuid, stepResult); lifecycle.stopStep(uuid); } }
/** * Returns Throwable exception * It can be overriden in extended Reporter * * @param result * @return Returns Throwable exception */ protected Throwable getError(Result result){ return result.getError(); }
public boolean hasResultErrorMessage() { return result != null && result.getErrorMessage() != null; } }
private String calculateTotalDurationString() { long totalDurationNanos = 0; for ( Result r : results ) { totalDurationNanos += r.getDuration() == null ? 0 : r.getDuration(); } for ( Result r : hookResults ) { totalDurationNanos += r.getDuration() == null ? 0 : r.getDuration(); } double totalDurationSeconds = ( (double) totalDurationNanos ) / 1000000000; return NUMBER_FORMAT.format( totalDurationSeconds ); }
private void before(Map o) { Map m = (Map) o.get("match"); Match match = new Match(arguments(m), location(m)); Map r = (Map) o.get("result"); Result result = new Result(status(r), duration(r), errorMessage(r)); reporter.before(match, result); }
private void becauseCucumberEndOfScenarioLifeCycle(Scenario scenario) { result.getErrorMessage(); Throwable error = result.getError(); + result.getStatus() + ""); logger.info(starthorizonline + passedMessage + failedMessage + skippedMessage + undefinedMessage + passedScenarioMessage + failedScenarioMessage + skippedScenarioMessage + undefinedScenarioMessage
/** * Gets the total number of passed tests. */ @Override public int getPassCount() { return CucumberUtils.PASSED_TEST_STRING.equals(result.getStatus()) ? 1 : 0; }
public StringBuilder addFailure(StringBuilder sb, Result result) { if (Result.FAILED.equals(result.getStatus())) { createLine(sb, "Failure", RESULT_TYPE.FAILED); String[] stack = result.getErrorMessage().split("\n"); sb.append(stack[0]).append("<br>"); for (int i = 1; i < stack.length; i++) { sb.append(stack[i].replaceAll("\t", " ")); sb.append("<br>"); } // Error is always null (only non null when invoked direct as part of the test). /* * Throwable t = result.getError(); if (t != null) { StackTraceElement stack[] = t.getStackTrace(); * for (StackTraceElement ste : stack) { sb.append(ste.toString()).append("<br>"); } } */ } else if ("undefined".equals(result.getStatus())) { createLine(sb, "Undefined", RESULT_TYPE.UNDEFINED); sb.append("Step is undefined"); // We have no error message. } endLine(sb); return sb; }
private void addStackTrace( StringBuilder sb, Result failed ) { sb.append( "\nStackTrace:\n" ); StringWriter sw = new StringWriter(); failed.getError().printStackTrace( new PrintWriter( sw ) ); sb.append( sw.toString() ); }
/** * Used at runtime * * @param status * @param duration * @param error * @param dummy only used to distinguish the constructor when used from JRuby (and null for error). */ public Result(String status, Long duration, Throwable error, Object dummy) { this.status = status; this.duration = duration; this.error_message = error != null ? getErrorMessage(error) : null; this.error = error; }
/** Get the duration (in seconds) that the result took. */ static float durationFromResult(Result result) { // internally this is in nanosecodes Long l = result.getDuration(); if (l == null) { return 0.0f; } return l.floatValue() / 1000000000.0f; }
private void after(Map o) { Map m = (Map) o.get("match"); Match match = new Match(arguments(m), location(m)); Map r = (Map) o.get("result"); Result result = new Result(status(r), duration(r), errorMessage(r)); reporter.after(match, result); }
public void before(Match match, Result result) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "rep before match: " + match.getLocation()); LOG.log(Level.FINE, "rep result : " + "(passed) " + Result.PASSED.equals(result.getStatus())); LOG.log(Level.FINE, "rep result : " + result.getDuration()); LOG.log(Level.FINE, "rep result : " + result.getErrorMessage()); LOG.log(Level.FINE, "rep result : " + result.getError()); } currentScenarioResult.addBeforeResult(new BeforeAfterResult(match, result)); }