• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Examples类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gherkin.ast.Examples的典型用法代码示例。如果您正苦于以下问题:Java Examples类的具体用法?Java Examples怎么用?Java Examples使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Examples类属于gherkin.ast包,在下文中一共展示了Examples类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createTestData

import gherkin.ast.Examples; //导入依赖的package包/类
private void createTestData(TestCase testCase, List<Examples> examples) {
    for (Examples example : examples) {
        TestDataModel tdModel = createTestData(testCase.getName());
        List<String> columns = new ArrayList<>();
        for (TableCell tCell : example.getTableHeader().getCells()) {
            columns.add(tCell.getValue());
            tdModel.addColumn(tCell.getValue());
        }
        for (int i = 0; i < example.getTableBody().size(); i++) {
            TableRow tRow = example.getTableBody().get(i);
            tdModel.addRecord();
            Record record = tdModel.getRecords().get(i);
            record.setScenario(testCase.getScenario().getName());
            record.setTestcase(testCase.getName());
            record.setIteration("1");
            record.setSubIteration("" + (i + 1));
            for (int j = 0; j < tRow.getCells().size(); j++) {
                tdModel.setValueAt(tRow.getCells().get(j).getValue(),
                        i,
                        tdModel.getColumnIndex(columns.get(j)));
            }
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:BddParser.java


示例2: convertGherkinExampleTableToCucableExampleMap

import gherkin.ast.Examples; //导入依赖的package包/类
/**
 * Converts a Gherkin example table to a map of columns (keys) and rows (values)
 *
 * @param exampleTable a Gherkin {@link Examples} instance.
 * @return a map where the keys are the column headers and the values are lists of strings.
 */
Map<String, List<String>> convertGherkinExampleTableToCucableExampleMap(Examples exampleTable) {
    Map<String, List<String>> exampleMap = new LinkedHashMap<>();

    List<TableCell> headerCells = exampleTable.getTableHeader().getCells();
    for (TableCell headerCell : headerCells) {
        exampleMap.put("<" + headerCell.getValue() + ">", new ArrayList<>());
    }
    Object[] columnKeys = exampleMap.keySet().toArray();

    List<TableRow> tableBody = exampleTable.getTableBody();
    for (TableRow tableRow : tableBody) {
        List<TableCell> cells = tableRow.getCells();
        for (int i = 0; i < cells.size(); i++) {
            String columnKey = (String) columnKeys[i];
            List<String> values = exampleMap.get(columnKey);
            values.add(cells.get(i).getValue());
        }
    }
    return exampleMap;
}
 
开发者ID:trivago,项目名称:cucable-plugin,代码行数:27,代码来源:GherkinToCucableConverter.java


示例3: scenarios

import gherkin.ast.Examples; //导入依赖的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;
}
 
开发者ID:mauriciotogneri,项目名称:green-coffee,代码行数:27,代码来源:GreenCoffeeConfig.java


示例4: matchingExamples

import gherkin.ast.Examples; //导入依赖的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;
}
 
开发者ID:temyers,项目名称:cucumber-jvm-parallel-plugin,代码行数:19,代码来源:TagFilter.java


示例5: getExamplesAsParameters

import gherkin.ast.Examples; //导入依赖的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());
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:12,代码来源:AllureCucumber2Jvm.java


示例6: compileScenarioOutline

import gherkin.ast.Examples; //导入依赖的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);
        }
    }
}
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:53,代码来源:Compiler.java


示例7: getSingleScenariosFromOutline

import gherkin.ast.Examples; //导入依赖的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;
}
 
开发者ID:trivago,项目名称:cucable-plugin,代码行数:56,代码来源:GherkinDocumentParser.java


示例8: compileScenarioOutline

import gherkin.ast.Examples; //导入依赖的package包/类
private void compileScenarioOutline(List<Pickle> pickles, List<PickleStep> backgroundSteps, ScenarioOutline scenarioOutline, List<Tag> featureTags) {
    if (scenarioOutline.getSteps().isEmpty())
        return;

    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),
                        asList(
                                pickleLocation(values.getLocation()),
                                pickleStepLocation(scenarioOutlineStep)
                        )
                );
                steps.add(pickleStep);
            }

            Pickle pickle = new Pickle(
                    interpolate(scenarioOutline.getName(), variableCells, valueCells),
                    steps,
                    pickleTags(tags),
                    asList(
                            pickleLocation(values.getLocation()),
                            pickleLocation(scenarioOutline.getLocation())
                    )
            );

            pickles.add(pickle);
        }
    }
}
 
开发者ID:mauriciotogneri,项目名称:green-coffee,代码行数:51,代码来源:Compiler.java


示例9: compileScenarioOutline

import gherkin.ast.Examples; //导入依赖的package包/类
private void compileScenarioOutline(List<Pickle> pickles, List<PickleStep> backgroundSteps, ScenarioOutline scenarioOutline, List<Tag> featureTags, String language) {
    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<>();
            if (!scenarioOutline.getSteps().isEmpty())
                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),
                        asList(
                                pickleLocation(values.getLocation()),
                                pickleStepLocation(scenarioOutlineStep)
                        )
                );
                steps.add(pickleStep);
            }

            Pickle pickle = new Pickle(
                    interpolate(scenarioOutline.getName(), variableCells, valueCells),
                    language,
                    steps,
                    pickleTags(tags),
                    asList(
                            pickleLocation(values.getLocation()),
                            pickleLocation(scenarioOutline.getLocation())
                    )
            );

            pickles.add(pickle);
        }
    }
}
 
开发者ID:cucumber,项目名称:gherkin-java,代码行数:50,代码来源:Compiler.java



注:本文中的gherkin.ast.Examples类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ScannerFactory类代码示例发布时间:2022-05-23
下一篇:
Java ObjectScene类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap