Java源码示例:cucumber.api.PickleStepTestStep
示例1
private synchronized void createTestStep(PickleStepTestStep testStep) {
String stepName = testStep.getStepText();
TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile.get(), testStep.getStepLine());
if (astNode != null) {
Step step = (Step) astNode.node;
try {
String name = stepName == null || stepName.isEmpty()
? step.getText().replace("<", "<").replace(">", ">")
: stepName;
ExtentTest t = scenarioThreadLocal.get()
.createNode(new GherkinKeyword(step.getKeyword().trim()), step.getKeyword() + name, testStep.getCodeLocation());
stepTestThreadLocal.set(t);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if (!testStep.getStepArgument().isEmpty()) {
Argument argument = testStep.getStepArgument().get(0);
if (argument instanceof PickleString) {
createDocStringMap((PickleString)argument);
} else if (argument instanceof PickleTable) {
List<PickleRow> rows = ((PickleTable) argument).getRows();
stepTestThreadLocal.get().pass(MarkupHelper.createTable(getPickleTable(rows)).getMarkup());
}
}
}
示例2
private void handleTestStepStarted(final TestStepStarted event) {
if (event.testStep instanceof PickleStepTestStep) {
final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep;
final String stepKeyword = Optional.ofNullable(
testSources.getKeywordFromSource(currentFeatureFile.get(), pickleStep.getStepLine())
).orElse("UNDEFINED");
final StepResult stepResult = new StepResult()
.setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText()))
.setStart(System.currentTimeMillis());
lifecycle.startStep(getTestCaseUuid(currentTestCase.get()), getStepUuid(pickleStep), stepResult);
pickleStep.getStepArgument().stream()
.filter(PickleTable.class::isInstance)
.findFirst()
.ifPresent(table -> createDataTableAttachment((PickleTable) table));
} else if (event.testStep instanceof HookTestStep) {
initHook((HookTestStep) event.testStep);
}
}
示例3
private void handleTestStepStarted(final TestStepStarted event) {
if (event.testStep instanceof PickleStepTestStep) {
final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep;
final String stepKeyword = Optional.ofNullable(
cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, pickleStep.getStepLine())
).orElse("UNDEFINED");
final StepResult stepResult = new StepResult()
.setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText()))
.setStart(System.currentTimeMillis());
lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(pickleStep), stepResult);
pickleStep.getStepArgument().stream()
.filter(PickleTable.class::isInstance)
.findFirst()
.ifPresent(table -> createDataTableAttachment((PickleTable) table));
} else if (event.testStep instanceof HookTestStep) {
initHook((HookTestStep) event.testStep);
}
}
示例4
private void handlePickleStep(final TestStepFinished event) {
final Status stepStatus = translateTestCaseStatus(event.result);
final StatusDetails statusDetails;
if (event.result.getStatus() == Result.Type.UNDEFINED) {
updateTestCaseStatus(Status.PASSED);
statusDetails =
getStatusDetails(new PendingException("TODO: implement me"))
.orElse(new StatusDetails());
lifecycle.updateTestCase(getTestCaseUuid(currentTestCase.get()), scenarioResult ->
scenarioResult
.setStatusDetails(statusDetails));
} else {
statusDetails =
getStatusDetails(event.result.getError())
.orElse(new StatusDetails());
updateTestCaseStatus(stepStatus);
}
if (!Status.PASSED.equals(stepStatus) && stepStatus != null) {
forbidTestCaseStatusChange.set(true);
}
final TagParser tagParser = new TagParser(currentFeature.get(), currentTestCase.get());
statusDetails
.setFlaky(tagParser.isFlaky())
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
lifecycle.updateStep(getStepUuid((PickleStepTestStep) event.testStep),
stepResult -> stepResult.setStatus(stepStatus).setStatusDetails(statusDetails));
lifecycle.stopStep(getStepUuid((PickleStepTestStep) event.testStep));
}
示例5
private void handleTestStepFinished(TestStepFinished event) {
if (event.testStep instanceof PickleStepTestStep) {
testMethod.steps.add((PickleStepTestStep) event.testStep);
testMethod.results.add(event.result);
} else {
testMethod.hooks.add(event.result);
}
}
示例6
private String getStepUuid(final PickleStepTestStep step) {
return currentFeature.get().getName() + getTestCaseUuid(currentTestCase.get())
+ step.getPickleStep().getText() + step.getStepLine();
}
示例7
private String getStepUuid(final PickleStepTestStep step) {
return currentFeature.getName() + getTestCaseUuid(currentTestCase)
+ step.getPickleStep().getText() + step.getStepLine();
}
示例8
private void handlePickleStep(final TestStepFinished event) {
final Status stepStatus = translateTestCaseStatus(event.result);
final StatusDetails statusDetails;
if (event.result.getStatus() == Result.Type.UNDEFINED) {
updateTestCaseStatus(Status.PASSED);
statusDetails =
getStatusDetails(new PendingException("TODO: implement me"))
.orElse(new StatusDetails());
lifecycle.updateTestCase(getTestCaseUuid(currentTestCase), scenarioResult ->
scenarioResult
.setStatusDetails(statusDetails));
} else {
statusDetails =
getStatusDetails(event.result.getError())
.orElse(new StatusDetails());
updateTestCaseStatus(stepStatus);
}
if (!Status.PASSED.equals(stepStatus) && stepStatus != null) {
forbidTestCaseStatusChange = true;
}
final TagParser tagParser = new TagParser(currentFeature, currentTestCase);
statusDetails
.setFlaky(tagParser.isFlaky())
.setMuted(tagParser.isMuted())
.setKnown(tagParser.isKnown());
lifecycle.updateStep(getStepUuid((PickleStepTestStep) event.testStep),
stepResult -> stepResult.setStatus(stepStatus).setStatusDetails(statusDetails));
lifecycle.stopStep(getStepUuid((PickleStepTestStep) event.testStep));
}