当前位置: 首页>>代码示例>>Java>>正文


Java Feature类代码示例

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


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

示例1: translate

import gherkin.ast.Feature; //导入依赖的package包/类
@Override
public SpecflowFileContents translate(Feature content, SpecflowFileContents scenarios, ITestFrameworkConstants constants) {
    String featureContent = String.format(BodyContent,
            constants.getExpectedClassAttributes(content.getName()),
            content.getName().replaceAll("[^A-Za-z0-9]", ""),
            constants.getTestFixtureSetupHeader(),
            content.getName(),
            content.getDescription(),
            constants.getTestFixtureTearDownHeader(),
            constants.getTestScenarioSetupHeader(),
            constants.getTestScenarioTearDownHeader(),
            scenarios.feature);
    String stepsContent = String.format(StepsFeatureBody,
            content.getName().replaceAll("[^A-Za-z0-9]", ""),
            scenarios.steps);
    return new SpecflowFileContents(featureContent,stepsContent);
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:18,代码来源:SpecflowTranslatorCSharp.java

示例2: createTestCases

import gherkin.ast.Feature; //导入依赖的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());
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:BddParser.java

示例3: compile

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

示例4: scenarios

import gherkin.ast.Feature; //导入依赖的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

示例5: compile

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

示例6: compile

import gherkin.ast.Feature; //导入依赖的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;
}
 
开发者ID:cucumber,项目名称:gherkin-java,代码行数:23,代码来源:Compiler.java

示例7: getFeature

import gherkin.ast.Feature; //导入依赖的package包/类
public Feature getFeature(final String path) {
    if (!pathToAstMap.containsKey(path)) {
        parseGherkinSource(path);
    }
    if (pathToAstMap.containsKey(path)) {
        return pathToAstMap.get(path).getFeature();
    }
    return null;
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:10,代码来源:CucumberSourceUtils.java

示例8: getKeywordFromSource

import gherkin.ast.Feature; //导入依赖的package包/类
public String getKeywordFromSource(final String uri, final int stepLine) {
    final Feature feature = getFeature(uri);
    if (feature != null) {
        final TestSourceRead event = getTestSourceReadEvent(uri);
        final String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
        final GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
        for (String keyword : dialect.getStepKeywords()) {
            if (trimmedSourceLine.startsWith(keyword)) {
                return keyword;
            }
        }
    }
    return "";
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:15,代码来源:CucumberSourceUtils.java

示例9: analyze

import gherkin.ast.Feature; //导入依赖的package包/类
@Override
public SpecflowFileContents analyze(String file, String namespace) {
    Feature feature = parser.parse(file).getFeature();
    SpecflowFileContents scenariosTranslate = translator.translate(feature.getChildren(), feature.getTags(), constants);
    SpecflowFileContents featureTranslate = translator.translate(feature,scenariosTranslate, constants);
    SpecflowFileContents FileTranslate = translator.translate(namespace,featureTranslate, constants);
    return FileTranslate;
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:9,代码来源:SpecflowAnalyzer.java

示例10: analizeCallsCorrectProcess

import gherkin.ast.Feature; //导入依赖的package包/类
@Test
public void analizeCallsCorrectProcess() throws Exception {
    Parser<GherkinDocument> parser = (Parser<GherkinDocument>) mock(Parser.class);
    ISpecflowTranslator translator = mock(ISpecflowTranslator.class);
    ITestFrameworkConstants constants = mock(ITestFrameworkConstants.class);

    String document = Faker.getRandomString();
    GherkinDocument gherkinDocument = mock(GherkinDocument.class);
    when(parser.parse(document)).thenReturn(gherkinDocument);
    Feature feature = mock(Feature.class);
    List<ScenarioDefinition> scenarios = new ArrayList<>();
    List<Tag> tags = new ArrayList<>();
    when(feature.getChildren()).thenReturn(scenarios);
    when(feature.getTags()).thenReturn(tags);

    when(gherkinDocument.getFeature()).thenReturn(feature);
    SpecflowFileContents translatedScenarios =new SpecflowFileContents(Faker.getRandomString(), Faker.getRandomString());
    SpecflowFileContents translatedFeature =new SpecflowFileContents(Faker.getRandomString(), Faker.getRandomString());
    SpecflowFileContents translatedFile =new SpecflowFileContents(Faker.getRandomString(), Faker.getRandomString());
    String namespace = Faker.getRandomString();
    when(translator.translate(scenarios, tags, constants)).thenReturn(translatedScenarios);
    when(translator.translate(feature, translatedScenarios,constants)).thenReturn(translatedFeature);
    when(translator.translate(namespace,translatedFeature, constants)).thenReturn(translatedFile);

    SpecflowAnalyzer analyzer = new SpecflowAnalyzer(parser, translator, constants);
    SpecflowFileContents contents = analyzer.analyze(document, namespace);

    verify(parser).parse(document);
    assertEquals(translatedFile.feature, contents.feature);
    assertEquals(translatedFile.steps, contents.steps);
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:32,代码来源:SpecflowAnalizerTest.java

示例11: translateFeatureTest

import gherkin.ast.Feature; //导入依赖的package包/类
@Test
public void translateFeatureTest() {

    SpecflowTranslatorCSharp translator = new SpecflowTranslatorCSharp();

    Feature feature = mock(Feature.class);
    ITestFrameworkConstants constants = mock(ITestFrameworkConstants.class);

    when(feature.getName()).thenReturn(Faker.getRandomString().replace('-', ' ') + "("+Faker.getRandomString()+"<>!)");
    when(feature.getDescription()).thenReturn(Faker.getRandomString().replace('-', ' ') + "("+Faker.getRandomString()+"<>!)");
    when(constants.getExpectedClassAttributes(feature.getName())).thenReturn(Faker.getRandomString());
    when(constants.getTestFixtureSetupHeader()).thenReturn(Faker.getRandomString());
    when(constants.getTestFixtureTearDownHeader()).thenReturn(Faker.getRandomString());
    when(constants.getTestScenarioSetupHeader()).thenReturn(Faker.getRandomString());
    when(constants.getTestScenarioTearDownHeader()).thenReturn(Faker.getRandomString());

    SpecflowFileContents scenarionContent = new SpecflowFileContents(Faker.getRandomString(), Faker.getRandomString());

    SpecflowFileContents contents = translator.translate(feature, scenarionContent, constants);
    String ExpectedFeatureContent = String.format(BodyContent,
            constants.getExpectedClassAttributes(feature.getName()),
            feature.getName().replaceAll("[^A-Za-z0-9]", ""),
            constants.getTestFixtureSetupHeader(),
            feature.getName(),
            feature.getDescription(),
            constants.getTestFixtureTearDownHeader(),
            constants.getTestScenarioSetupHeader(),
            constants.getTestScenarioTearDownHeader(),
            scenarionContent.feature);

    String ExpectedStepsContent = String.format(StepsFeatureBody,
            feature.getName().replaceAll("[^A-Za-z0-9]", ""),
            scenarionContent.steps);
    assertEquals(ExpectedFeatureContent, contents.feature);
    assertEquals(ExpectedStepsContent, contents.steps);
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:37,代码来源:SpecflowTranslatorCSharpTest.java

示例12: parse

import gherkin.ast.Feature; //导入依赖的package包/类
public void parse(File file) {
    if (file != null && file.exists()) {
        try {
            Feature feature = GHERKIN_PARSER.parse(new FileReader(file)).getFeature();
            String featureName = feature.getName();
            createTestCases(updateInfo(create(featureName), feature),
                    feature);
            File tp = new File(sMainFrame.getProject().getLocation(), "TestPlan");
            Files.copy(file, new File(tp, file.getName()));
        } catch (Exception ex) {
            Logger.getLogger(BddParser.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:BddParser.java

示例13: updateInfo

import gherkin.ast.Feature; //导入依赖的package包/类
private Scenario updateInfo(Scenario scn, Feature feature) {
    String desc = feature.getDescription();
    List<Tag> tags = toTag(feature.getTags());
    Meta metaRes = pModel().findScenario(scn.getName())
            .orElseGet(() -> {
                Meta meta = Meta.createScenario(scn.getName());
                pModel().addMeta(meta);
                return meta;
            });
    metaRes.setTags(tags);
    metaRes.getAttributes().add(Attribute.create("feature.line", feature.getLocation().getLine()));
    metaRes.setDesc(desc);
    return scn;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:BddParser.java

示例14: backgrounds

import gherkin.ast.Feature; //导入依赖的package包/类
private List<ScenarioDefinition> backgrounds(Feature feature)
{
    List<ScenarioDefinition> result = new ArrayList<>();

    for (ScenarioDefinition scenario : feature.getChildren())
    {
        if (gherkin.ast.Background.class.isInstance(scenario))
        {
            result.add(scenario);
        }
    }

    return result;
}
 
开发者ID:mauriciotogneri,项目名称:green-coffee,代码行数:15,代码来源:GreenCoffeeConfig.java

示例15: generateCucumberITFiles

import gherkin.ast.Feature; //导入依赖的package包/类
/**
 * Generates a single Cucumber runner for each separate feature file.
 *
 * @param outputDirectory the output directory to place generated files
 * @param featureFiles    The feature files to create runners for
 * @throws MojoExecutionException if something goes wrong
 */
public void generateCucumberITFiles(final File outputDirectory,
                                    final Collection<File> featureFiles) throws MojoExecutionException {
    final Parser<Feature> parser = new Parser<Feature>(new AstBuilder());
    Feature feature = null;
    for (final File file : featureFiles) {

        try {
            feature = parser.parse(new FileReader(file), new TokenMatcher());
        } catch (final FileNotFoundException e) {
            // should never happen
            // TODO - proper logging
            System.out.println(format("WARNING: Failed to parse '%s'...IGNORING",
                    file.getName()));
        }

        if (shouldSkipFeature(feature)) {
            continue;
        }


        outputFileName = classNamingScheme.generate(file.getName());
        setFeatureFileLocation(file);
        setParsedFeature(feature);
        writeFile(outputDirectory);

    }
}
 
开发者ID:temyers,项目名称:cucumber-jvm-parallel-plugin,代码行数:35,代码来源:CucumberITGeneratorByFeature.java


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