public String getMatchLocation() { if (match != null) { return match.getLocation(); } return null; }
public MatchExec convertMatch(Match match) { return new MatchExec( match.getLocation(), convertArguments(match.getArguments())); }
public Match getOutlineMatch(String location) { return new Match(getOutlineArgs(), location); }
@Override public void match(Match match) { List<Argument> inflatedArguments = new ArrayList<>(); for (Argument argument : match.getArguments()) { String inflatedVal = contextInflater.inflate(argument.getVal()); inflatedArguments.add(new Argument(argument.getOffset(), inflatedVal)); } super.match(new Match(inflatedArguments, match.getLocation())); Map<String, Object> currentStep = getCurrentStep(); if (currentStep != null) { String name = ((String) currentStep.get("name")); String inflatedName = contextInflater.inflate(name); currentStep.put("name", inflatedName); } }
public List<Argument> getMatchArguments() { if (match != null) { return match.getArguments(); } return Collections.<Argument>emptyList(); }
private Map buildHookMap(final Match match, final Result result) { final Map hookMap = new HashMap(); hookMap.put("match", match.toMap()); hookMap.put("result", result.toMap()); return hookMap; }
@Override public void match(Match match) { getCurrentStep(Phase.match).put("match", match.toMap()); }
public void match(Match match) { // applies to a step. LOG.log(Level.FINE, "rep match: {0}", match.getLocation()); if (currentMatch != null) { LOG.log(Level.SEVERE, "Match: " + match.getLocation() + " received before previous Match: " + currentMatch.getLocation()+ "handled"); throw new CucumberModelException("Match: " + match.getLocation() + " received before previous Match: " + currentMatch.getLocation()+ "handled"); } currentMatch = match; }
public StringBuilder addBeforeAfterResult(StringBuilder sb, String beforeOrAfter, BeforeAfterResult beforeAfter) { Match m = beforeAfter.getMatch(); Result r = beforeAfter.getResult(); createLine(sb, beforeOrAfter, RESULT_TYPE.typeFromResult(r)); sb.append(m.getLocation()).append(' '); addFailure(sb, r); // XXX add argument formatting List<Argument> args = m.getArguments(); endLine(sb); return sb; }
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); }
@Override protected void hookFinished(Match match, Result result, Boolean isBefore) { reportResult(result, (isBefore ? "Before" : "After") + " hook: " + match.getLocation()); if (result.getStatus().equals("failed")) { hookStatus = Statuses.FAILED; } }
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); }
public void after(Match match, Result result) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "rep after 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.addAfterResult(new BeforeAfterResult(match, result)); }
private void runHookIfTagsMatch(HookDefinition hook, Reporter reporter, Set<Tag> tags, boolean isBefore) { if (hook.matches(tags)) { String status = Result.PASSED; Throwable error = null; Match match = new Match(Collections.<Argument>emptyList(), hook.getLocation(false)); stopWatch.start(); try { hook.execute(scenarioResult); } catch (Throwable t) { error = t; if (isPending(t)) { status = "pending"; } else { status = Result.FAILED; } addError(t); skipNextStep = true; } finally { long duration = stopWatch.stop(); Result result = new Result(status, duration, error, DUMMY_ARG); addHookToCounterAndResult(result); if (isBefore) { reporter.before(match, result); } else { 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)); }
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); } } }
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); } }