本文整理汇总了Java中gherkin.ast.ScenarioOutline类的典型用法代码示例。如果您正苦于以下问题:Java ScenarioOutline类的具体用法?Java ScenarioOutline怎么用?Java ScenarioOutline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScenarioOutline类属于gherkin.ast包,在下文中一共展示了ScenarioOutline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processScenarioOutlineExamples
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private void processScenarioOutlineExamples(
final Map<Integer, AstNode> nodeMap, final ScenarioOutline scenarioOutline, final AstNode childNode
) {
scenarioOutline.getExamples().forEach(examples -> {
final AstNode examplesNode = new AstNode(examples, childNode);
final TableRow headerRow = examples.getTableHeader();
final AstNode headerNode = new AstNode(headerRow, examplesNode);
nodeMap.put(headerRow.getLocation().getLine(), headerNode);
IntStream.range(0, examples.getTableBody().size()).forEach(i -> {
final TableRow examplesRow = examples.getTableBody().get(i);
final Node rowNode = new CucumberSourceUtils.ExamplesRowWrapperNode(examplesRow, i);
final AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode);
nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode);
});
});
}
示例2: createTestCases
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private void createTestCases(Scenario scenario, Feature feature) {
for (ScenarioDefinition scenarioDef : feature.getChildren()) {
String scenDefName = scenarioDef.getName();
TestCase testCase = updateInfo(createTestCase(scenario, scenDefName), scenarioDef);
testCase.clearSteps();
for (Step step : scenarioDef.getSteps()) {
String reusableName = convert(step.getText());
TestCase reusable = updateInfo(createReusable(create("StepDefinitions"), reusableName), step);
if (reusable != null) {
reusable.addNewStep()
.setInput(getInputField(testCase.getName(), step.getText()))
.setDescription(getDescription(step));
}
testCase.addNewStep()
.asReusableStep("StepDefinitions", reusableName)
.setDescription(getDescription(step));
}
if (scenarioDef instanceof ScenarioOutline) {
ScenarioOutline scOutline = (ScenarioOutline) scenarioDef;
createTestData(testCase, scOutline.getExamples());
}
}
}
示例3: compile
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
public List<Pickle> compile(GherkinDocument gherkinDocument, String path) {
List<Pickle> pickles = new ArrayList<>();
Feature feature = gherkinDocument.getFeature();
if (feature == null) {
return pickles;
}
List<Tag> featureTags = feature.getTags();
List<PickleStep> backgroundSteps = new ArrayList<>();
for (ScenarioDefinition scenarioDefinition : feature.getChildren()) {
if (scenarioDefinition instanceof Background) {
backgroundSteps = pickleSteps(scenarioDefinition, path);
} else if (scenarioDefinition instanceof Scenario) {
compileScenario(pickles, backgroundSteps, (Scenario) scenarioDefinition, featureTags, path);
} else {
compileScenarioOutline(pickles, backgroundSteps, (ScenarioOutline) scenarioDefinition, featureTags, path);
}
}
return pickles;
}
示例4: scenarios
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private List<ScenarioDefinition> scenarios(Feature feature)
{
List<ScenarioDefinition> result = new ArrayList<>();
for (ScenarioDefinition scenario : feature.getChildren())
{
if (isScenarioNormal(scenario))
{
result.add(scenario);
}
else if (isScenarioOutline(scenario))
{
ScenarioOutline scenarioOutline = (ScenarioOutline) scenario;
for (Examples examples : scenarioOutline.getExamples())
{
for (TableRow row : examples.getTableBody())
{
result.add(concreteScenario(scenarioOutline, parametersMap(examples.getTableHeader(), row)));
}
}
}
}
return result;
}
示例5: concreteScenario
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private ScenarioDefinition concreteScenario(ScenarioOutline abstractScenario, Map<String, String> parameters)
{
List<Step> steps = new ArrayList<>();
for (Step step : abstractScenario.getSteps())
{
steps.add(concreteStep(step, parameters));
}
return new gherkin.ast.Scenario(
abstractScenario.getTags(),
abstractScenario.getLocation(),
abstractScenario.getKeyword(),
abstractScenario.getName(),
abstractScenario.getDescription(),
steps);
}
示例6: compile
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
public List<Pickle> compile(GherkinDocument gherkinDocument) {
List<Pickle> pickles = new ArrayList<>();
Feature feature = gherkinDocument.getFeature();
if (feature == null) {
return pickles;
}
List<Tag> featureTags = feature.getTags();
List<PickleStep> backgroundSteps = new ArrayList<>();
for (ScenarioDefinition scenarioDefinition : feature.getChildren()) {
if (scenarioDefinition instanceof Background) {
backgroundSteps = pickleSteps(scenarioDefinition);
} else if (scenarioDefinition instanceof Scenario) {
compileScenario(pickles, backgroundSteps, (Scenario) scenarioDefinition, featureTags);
} else {
compileScenarioOutline(pickles, backgroundSteps, (ScenarioOutline) scenarioDefinition, featureTags);
}
}
return pickles;
}
示例7: matchingExamples
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private Collection<ScenarioAndLocation> matchingExamples(final ScenarioOutline scenario,
final Set<Tag> allTagsForScenario) {
final Collection<ScenarioAndLocation> matchingRows =
new LinkedList<ScenarioAndLocation>();
for (final Examples example : scenario.getExamples()) {
final Collection<Tag> allTagsForExample = new HashSet<Tag>(allTagsForScenario);
allTagsForExample.addAll(example.getTags());
if (matches(allTagsForExample)) {
for (TableRow row : example.getTableBody()) {
matchingRows.add(new ScenarioAndLocation(scenario, row.getLocation()));
}
}
}
return matchingRows;
}
示例8: compile
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
public List<Pickle> compile(GherkinDocument gherkinDocument) {
List<Pickle> pickles = new ArrayList<>();
Feature feature = gherkinDocument.getFeature();
if (feature == null) {
return pickles;
}
String language = feature.getLanguage();
List<Tag> featureTags = feature.getTags();
List<PickleStep> backgroundSteps = new ArrayList<>();
for (ScenarioDefinition scenarioDefinition : feature.getChildren()) {
if (scenarioDefinition instanceof Background) {
backgroundSteps = pickleSteps(scenarioDefinition);
} else if (scenarioDefinition instanceof Scenario) {
compileScenario(pickles, backgroundSteps, (Scenario) scenarioDefinition, featureTags, language);
} else {
compileScenarioOutline(pickles, backgroundSteps, (ScenarioOutline) scenarioDefinition, featureTags, language);
}
}
return pickles;
}
示例9: handleTestCaseStarted
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private void handleTestCaseStarted(final TestCaseStarted event) {
currentFeatureFile = event.testCase.getUri();
currentFeature = cucumberSourceUtils.getFeature(currentFeatureFile);
currentTestCase = event.testCase;
final Deque<PickleTag> tags = new LinkedList<>();
tags.addAll(event.testCase.getTags());
final LabelBuilder labelBuilder = new LabelBuilder(currentFeature, event.testCase, tags);
final TestResult result = new TestResult()
.withUuid(getTestCaseUuid(event.testCase))
.withHistoryId(getHistoryId(event.testCase))
.withName(event.testCase.getName())
.withLabels(labelBuilder.getScenarioLabels())
.withLinks(labelBuilder.getScenarioLinks());
final ScenarioDefinition scenarioDefinition =
cucumberSourceUtils.getScenarioDefinition(currentFeatureFile, currentTestCase.getLine());
if (scenarioDefinition instanceof ScenarioOutline) {
result.withParameters(
getExamplesAsParameters((ScenarioOutline) scenarioDefinition)
);
}
if (currentFeature.getDescription() != null && !currentFeature.getDescription().isEmpty()) {
result.withDescription(currentFeature.getDescription());
}
lifecycle.scheduleTestCase(result);
lifecycle.startTestCase(getTestCaseUuid(event.testCase));
}
示例10: getExamplesAsParameters
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private List<Parameter> getExamplesAsParameters(final ScenarioOutline scenarioOutline) {
final Examples examples = scenarioOutline.getExamples().get(0);
final TableRow row = examples.getTableBody().stream()
.filter(example -> example.getLocation().getLine() == currentTestCase.getLine())
.findFirst().get();
return IntStream.range(0, examples.getTableHeader().getCells().size()).mapToObj(index -> {
final String name = examples.getTableHeader().getCells().get(index).getValue();
final String value = row.getCells().get(index).getValue();
return new Parameter().withName(name).withValue(value);
}).collect(Collectors.toList());
}
示例11: processScenarioDefinition
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private void processScenarioDefinition(
final Map<Integer, AstNode> nodeMap, final ScenarioDefinition child, final AstNode currentParent
) {
final AstNode childNode = new AstNode(child, currentParent);
nodeMap.put(child.getLocation().getLine(), childNode);
child.getSteps().forEach(
step -> nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode))
);
if (child instanceof ScenarioOutline) {
processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode);
}
}
示例12: getTags
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private List getTags(ScenarioDefinition sdef) {
if (sdef instanceof ScenarioOutline) {
return ((ScenarioOutline) sdef).getTags();
} else if (sdef instanceof gherkin.ast.Scenario) {
return ((gherkin.ast.Scenario) sdef).getTags();
} else {
return null;
}
}
示例13: compileScenarioOutline
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
private void compileScenarioOutline(List<Pickle> pickles, List<PickleStep> backgroundSteps, ScenarioOutline scenarioOutline, List<Tag> featureTags, String path) {
if (scenarioOutline.getSteps().isEmpty())
return;
int exampleCount = 1;
for (final Examples examples : scenarioOutline.getExamples()) {
if (examples.getTableHeader() == null) continue;
List<TableCell> variableCells = examples.getTableHeader().getCells();
for (final TableRow values : examples.getTableBody()) {
List<TableCell> valueCells = values.getCells();
List<PickleStep> steps = new ArrayList<>();
steps.addAll(backgroundSteps);
List<Tag> tags = new ArrayList<>();
tags.addAll(featureTags);
tags.addAll(scenarioOutline.getTags());
tags.addAll(examples.getTags());
for (Step scenarioOutlineStep : scenarioOutline.getSteps()) {
String stepText = interpolate(scenarioOutlineStep.getText(), variableCells, valueCells);
// TODO: Use an Array of location in DataTable/DocString as well.
// If the Gherkin AST classes supported
// a list of locations, we could just reuse the same classes
PickleStep pickleStep = new PickleStep(
stepText,
createPickleArguments(scenarioOutlineStep.getArgument(), variableCells, valueCells, path),
asList(
pickleLocation(values.getLocation(), path),
pickleStepLocation(scenarioOutlineStep, path)
),
scenarioOutlineStep.getKeyword().trim()
);
steps.add(pickleStep);
}
Pickle pickle = new Pickle(
interpolate(scenarioOutline.getName(), variableCells, valueCells)+ " Example No." + exampleCount++,
steps,
pickleTags(tags, path),
asList(
pickleLocation(values.getLocation(), path),
pickleLocation(scenarioOutline.getLocation(), path)
)
);
pickles.add(pickle);
}
}
}
示例14: getSingleScenariosFromFeature
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
/**
* Returns a {@link com.trivago.rta.vo.SingleScenario} list from a given feature file.
*
* @param featureContent a feature string.
* @param scenarioLineNumber an optional line number of a scenario inside a feature file.
* @param includeScenarioTags optional scenario tags to include into scenario generation.
* @param excludeScenarioTags optional scenario tags to exclude from scenario generation.
* @return a {@link com.trivago.rta.vo.SingleScenario} list.
* @throws CucablePluginException see {@link CucablePluginException}.
*/
public List<SingleScenario> getSingleScenariosFromFeature(
final String featureContent,
final Integer scenarioLineNumber,
final List<String> includeScenarioTags,
final List<String> excludeScenarioTags) throws CucablePluginException {
GherkinDocument gherkinDocument = getGherkinDocumentFromFeatureFileContent(featureContent);
Feature feature = gherkinDocument.getFeature();
String featureName = feature.getName();
List<String> featureTags =
gherkinToCucableConverter.convertGherkinTagsToCucableTags(feature.getTags());
ArrayList<SingleScenario> singleScenarioFeatures = new ArrayList<>();
List<Step> backgroundSteps = new ArrayList<>();
List<ScenarioDefinition> scenarioDefinitions = feature.getChildren();
for (ScenarioDefinition scenarioDefinition : scenarioDefinitions) {
String scenarioName = scenarioDefinition.getName();
if (scenarioDefinition instanceof Background) {
// Save background steps in order to add them to every scenario inside the same feature
Background background = (Background) scenarioDefinition;
backgroundSteps = gherkinToCucableConverter.convertGherkinStepsToCucableSteps(background.getSteps());
continue;
}
if (scenarioDefinition instanceof Scenario) {
Scenario scenario = (Scenario) scenarioDefinition;
if (scenarioLineNumber == null || scenario.getLocation().getLine() == scenarioLineNumber) {
SingleScenario singleScenario =
new SingleScenario(featureName, scenarioName, featureTags, backgroundSteps);
addGherkinScenarioInformationToSingleScenario(scenario, singleScenario);
if (scenarioShouldBeIncluded(singleScenario.getScenarioTags(), singleScenario.getFeatureTags(), includeScenarioTags, excludeScenarioTags)) {
singleScenarioFeatures.add(singleScenario);
}
}
continue;
}
if (scenarioDefinition instanceof ScenarioOutline) {
ScenarioOutline scenarioOutline = (ScenarioOutline) scenarioDefinition;
if (scenarioLineNumber == null || scenarioOutline.getLocation().getLine() == scenarioLineNumber) {
List<SingleScenario> outlineScenarios =
getSingleScenariosFromOutline(
scenarioOutline,
featureName,
featureTags,
backgroundSteps,
includeScenarioTags,
excludeScenarioTags);
singleScenarioFeatures.addAll(outlineScenarios);
}
}
}
return singleScenarioFeatures;
}
示例15: getSingleScenariosFromOutline
import gherkin.ast.ScenarioOutline; //导入依赖的package包/类
/**
* Returns a list of Cucable single scenarios from a Gherkin scenario outline.
*
* @param scenarioOutline a Gherkin {@link ScenarioOutline}.
* @param featureName The name of the feature this scenario outline belongs to.
* @param featureTags The feature tags of the parent feature.
* @param backgroundSteps return a Cucable {@link SingleScenario} list.
* @param includeScenarioTags optional scenario tags to include in scenario generation.
* @param excludeScenarioTags optional scenario tags to exclude from scenario generation.
* @throws CucablePluginException thrown when the scenario outline does not contain an example table.
*/
private List<SingleScenario> getSingleScenariosFromOutline(
final ScenarioOutline scenarioOutline,
final String featureName,
final List<String> featureTags,
final List<Step> backgroundSteps,
final List<String> includeScenarioTags,
final List<String> excludeScenarioTags) throws CucablePluginException {
String scenarioName = scenarioOutline.getName();
List<String> scenarioTags =
gherkinToCucableConverter.convertGherkinTagsToCucableTags(scenarioOutline.getTags());
if (!scenarioShouldBeIncluded(featureTags, scenarioTags, includeScenarioTags, excludeScenarioTags)) {
return Collections.emptyList();
}
List<SingleScenario> outlineScenarios = new ArrayList<>();
List<Step> steps = gherkinToCucableConverter.convertGherkinStepsToCucableSteps(scenarioOutline.getSteps());
if (scenarioOutline.getExamples().isEmpty()) {
throw new CucablePluginException("Scenario outline without examples table!");
}
Examples exampleTable = scenarioOutline.getExamples().get(0);
Map<String, List<String>> exampleMap =
gherkinToCucableConverter.convertGherkinExampleTableToCucableExampleMap(exampleTable);
String firstColumnHeader = (String) exampleMap.keySet().toArray()[0];
int rowCount = exampleMap.get(firstColumnHeader).size();
// for each example row, create a new single scenario
for (int i = 0; i < rowCount; i++) {
SingleScenario singleScenario =
new SingleScenario(featureName, scenarioName, featureTags, backgroundSteps);
List<Step> substitutedSteps = substituteStepExamplePlaceholders(steps, exampleMap, i);
singleScenario.setSteps(substitutedSteps);
singleScenario.setScenarioTags(scenarioTags);
outlineScenarios.add(singleScenario);
}
return outlineScenarios;
}