use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.
the class CucumberScenarioOutlineTest method allows_doc_strings_to_be_empty_after_replacement.
@Test
public void allows_doc_strings_to_be_empty_after_replacement() {
Step outlineStep = new Step(C, null, "Some step", 0, null, new DocString(null, "<doc string>", 1));
Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("doc string"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
assertEquals("", exampleStep.getDocString().getValue());
}
use of gherkin.formatter.model.Step in project intellij-plugins by JetBrains.
the class JavaStepDefinitionCreator method buildStepDefinitionByStep.
private static PsiMethod buildStepDefinitionByStep(@NotNull final GherkinStep step, Language language) {
String annotationPackage = new AnnotationPackageProvider().getAnnotationPackageFor(step);
String methodAnnotation = String.format("@%s.", annotationPackage);
final Step cucumberStep = new Step(new ArrayList<>(), step.getKeyword().getText(), step.getStepName(), 0, null, null);
final SnippetGenerator generator = new SnippetGenerator(new JavaSnippet());
final String snippet = generator.getSnippet(cucumberStep, new FunctionNameGenerator(new CamelCaseConcatenator())).replace("PendingException", CucumberJavaUtil.getCucumberPendingExceptionFqn(step)).replaceFirst("@", methodAnnotation).replaceAll("\\\\\\\\", "\\\\").replaceAll("\\\\d", "\\\\\\\\d");
JVMElementFactory factory = JVMElementFactories.requireFactory(language, step.getProject());
return factory.createMethodFromText(snippet, step);
}
use of gherkin.formatter.model.Step in project intellij-plugins by JetBrains.
the class GrStepDefinitionCreator method buildStepDefinitionByStep.
private static GrMethodCall buildStepDefinitionByStep(@NotNull final GherkinStep step) {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(step.getProject());
final Step cucumberStep = new Step(Collections.emptyList(), step.getKeyword().getText(), step.getStepName(), 0, null, null);
SnippetGenerator generator = new SnippetGenerator(new GroovySnippet());
final String fqnPendingException;
if (GrCucumberUtil.isCucumber_1_1_orAbove(step)) {
fqnPendingException = "cucumber.api.PendingException";
} else {
fqnPendingException = "cucumber.runtime.PendingException";
}
String snippet = generator.getSnippet(cucumberStep, null).replace("PendingException", fqnPendingException);
return (GrMethodCall) factory.createStatementFromText(snippet, step);
}
use of gherkin.formatter.model.Step in project allure-cucumberjvm by allure-framework.
the class AllureReporter method extractStep.
private Step extractStep(StepDefinitionMatch match) {
try {
Field step = match.getClass().getDeclaredField("step");
step.setAccessible(true);
return (Step) step.get(match);
} catch (ReflectiveOperationException e) {
//shouldn't ever happen
LOG.error(e.getMessage(), e);
throw new CucumberException(e);
}
}
use of gherkin.formatter.model.Step in project allure-cucumberjvm by allure-framework.
the class AllureReporter method match.
@Override
public void match(Match match) {
if (match instanceof StepDefinitionMatch) {
this.match = (StepDefinitionMatch) match;
Step step = extractStep(this.match);
synchronized (gherkinSteps) {
while (gherkinSteps.peek() != null && !isEqualSteps(step, gherkinSteps.peek())) {
fireCanceledStep(gherkinSteps.remove());
}
if (isEqualSteps(step, gherkinSteps.peek())) {
gherkinSteps.remove();
}
}
String name = this.getStepName(step);
ALLURE_LIFECYCLE.fire(new StepStartedEvent(name).withTitle(name));
createDataTableAttachment(step.getRows());
}
}
Aggregations