@Override public StepResult withStart(Long value) { setStart(value); return this; }
/** * @deprecated use set method. Scheduled to removal in 3.0 release. */ @Deprecated @Override public StepResult withStart(final Long value) { return setStart(value); }
/** * Start a new step as child of specified parent. * * @param parentUuid the uuid of parent test case or step. * @param uuid the uuid of step. * @param result the step. */ public void startStep(final String parentUuid, final String uuid, final StepResult result) { notifier.beforeStepStart(result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.start(uuid); storage.put(uuid, result); storage.get(parentUuid, WithSteps.class).ifPresent(parentStep -> { synchronized (storage) { parentStep.getSteps().add(result); } }); notifier.afterStepStart(result); }
@Override public void match(final Match match) { final StepUtils stepUtils = new StepUtils(currentFeature, currentScenario); if (match instanceof StepDefinitionMatch) { isNullMatch = false; final Step step = stepUtils.extractStep((StepDefinitionMatch) match); synchronized (gherkinSteps) { while (gherkinSteps.peek() != null && !stepUtils.isEqualSteps(step, gherkinSteps.peek())) { stepUtils.fireCanceledStep(gherkinSteps.remove()); } if (stepUtils.isEqualSteps(step, gherkinSteps.peek())) { gherkinSteps.remove(); } } final StepResult stepResult = new StepResult(); stepResult.setName(String.format("%s %s", step.getKeyword(), getStepName(step))) .setStart(System.currentTimeMillis()); final String scenarioUuid = scenarioUuids.get(currentScenario); lifecycle.startStep(scenarioUuid, stepUtils.getStepUuid(step), stepResult); createDataTableAttachment(step.getRows()); } }
private void handleTestStepStarted(final TestStepStarted event) { if (event.testStep instanceof PickleStepTestStep) { final PickleStepTestStep pickleStepTestStep = (PickleStepTestStep) event.testStep; final String stepKeyword = Optional.ofNullable( cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, pickleStepTestStep.getStepLine()) ).orElse("UNDEFINED"); final StepResult stepResult = new StepResult() .setName(String.format("%s %s", stepKeyword, pickleStepTestStep.getPickleStep().getText())) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(event.testStep), stepResult); pickleStepTestStep.getStepArgument().stream() .filter(PickleTable.class::isInstance) .findFirst() .ifPresent(table -> createDataTableAttachment((PickleTable) table)); } else if (event.testStep instanceof HookTestStep) { final HookTestStep hookTestStep = (HookTestStep) event.testStep; final StepResult stepResult = new StepResult() .setName(hookTestStep.getHookType().toString()) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase), getHookStepUuid(event.testStep), stepResult); } else { throw new IllegalStateException(); } }
private void handleTestStepStarted(final TestStepStarted event) { if (!event.testStep.isHook()) { final String stepKeyword = Optional.ofNullable( cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, event.testStep.getStepLine()) ).orElse("UNDEFINED"); final StepResult stepResult = new StepResult() .setName(String.format("%s %s", stepKeyword, event.testStep.getPickleStep().getText())) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(event.testStep), stepResult); event.testStep.getStepArgument().stream() .filter(PickleTable.class::isInstance) .findFirst() .ifPresent(table -> createDataTableAttachment((PickleTable) table)); } else if (event.testStep.isHook() && event.testStep instanceof UnskipableStep) { final StepResult stepResult = new StepResult() .setName(event.testStep.getHookType().toString()) .setStart(System.currentTimeMillis()); lifecycle.startStep(getTestCaseUuid(currentTestCase), getHookStepUuid(event.testStep), stepResult); } }
@Override public void onEvent(final LogEvent event) { lifecycle.getCurrentTestCase().ifPresent(uuid -> { final String stepUUID = UUID.randomUUID().toString(); lifecycle.startStep(stepUUID, new StepResult() .setName(event.toString()) .setStatus(Status.PASSED)); lifecycle.updateStep(stepResult -> stepResult.setStart(stepResult.getStart() - event.getDuration())); if (LogEvent.EventStatus.FAIL.equals(event.getStatus())) { if (saveScreenshots) { lifecycle.addAttachment("Screenshot", "image/png", "png", getScreenshotBytes()); } if (savePageHtml) { lifecycle.addAttachment("Page source", "text/html", "html", getPageSourceBytes()); } lifecycle.updateStep(stepResult -> { final StatusDetails details = ResultsUtils.getStatusDetails(event.getError()) .orElse(new StatusDetails()); stepResult.setStatus(ResultsUtils.getStatus(event.getError()).orElse(Status.BROKEN)); stepResult.setStatusDetails(details); }); } lifecycle.stopStep(stepUUID); }); }
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); } }
protected void fireCanceledStep(final Step unimplementedStep) { final StepResult stepResult = new StepResult(); stepResult.setName(unimplementedStep.getName()) .setStart(System.currentTimeMillis()) .setStop(System.currentTimeMillis()) .setStatus(Status.SKIPPED) .setStatusDetails(new StatusDetails().setMessage("Unimplemented step")); lifecycle.startStep(scenario.getId(), getStepUuid(unimplementedStep), stepResult); lifecycle.stopStep(getStepUuid(unimplementedStep)); final StatusDetails statusDetails = new StatusDetails(); final TagParser tagParser = new TagParser(feature, scenario); statusDetails .setFlaky(tagParser.isFlaky()) .setMuted(tagParser.isMuted()) .setKnown(tagParser.isKnown()); lifecycle.updateTestCase(scenario.getId(), scenarioResult -> scenarioResult.setStatus(Status.SKIPPED) .setStatusDetails(statusDetails .setMessage("Unimplemented steps were found"))); }