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


Java Step类代码示例

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


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

示例1: getArguments

import gherkin.ast.Step; //导入依赖的package包/类
protected Object[] getArguments(Step step, StepImplementation implementation) {
	Method method = implementation.getMethod();
	Parameter[] parameters = method.getParameters();
	Object[] arguments = new Object[parameters.length];

	if (parameters.length > 0) {
		String text = step.getText();
		Pattern pattern = implementation.getPattern();
		Matcher matcher = pattern.matcher(text);
		checkState(matcher.find(),
			"unable to locate substitution parameters for pattern %s with input %s", pattern.pattern(), text);

		int groupCount = matcher.groupCount();
		ConversionService conversionService = SpringPreProcessor.getBean(ConversionService.class);
		for (int i = 0; i < groupCount; i++) {
			String parameterAsString = matcher.group(i + 1);
			Parameter parameter = parameters[i];
			Class<?> parameterType = parameter.getType();

			Object converted = conversionService.convert(parameterAsString, parameterType);
			arguments[i] = converted;
		}
	}
	return arguments;
}
 
开发者ID:qas-guru,项目名称:martini-jmeter-extension,代码行数:26,代码来源:MartiniSamplerClient.java

示例2: testGetParameterizedMartini

import gherkin.ast.Step; //导入依赖的package包/类
@SuppressWarnings("Guava")
@Test
public void testGetParameterizedMartini() throws NoSuchMethodException {
	String id = "Parameterized_Method_Calls:A_Parameterized_Case:25";
	Martini martini = getMartini(id);
	checkState(null != martini, "no Martini found matching ID [%s]", id);

	Map<Step, StepImplementation> stepIndex = martini.getStepIndex();
	Collection<StepImplementation> implementations = stepIndex.values();
	ImmutableList<StepImplementation> filtered = FluentIterable.from(implementations)
		.filter(notNull())
		.filter(Predicates.not(Predicates.instanceOf(UnimplementedStep.class)))
		.toList();
	assertFalse(filtered.isEmpty(), "expected at least one implementation");
	StepImplementation givenImplementation = filtered.get(0);

	Pattern pattern = givenImplementation.getPattern();
	assertNotNull(pattern, "expected implementation to have a Pattern");

	String regex = pattern.pattern();
	assertEquals(regex, "^a pre-existing condition known as \"(.+)\"$", "Pattern contains wrong regex");

	Method method = givenImplementation.getMethod();
	Method expected = ParameterizedTestSteps.class.getDeclaredMethod("aPreExistingConditionKnownAs", String.class);
	assertEquals(method, expected, "implementation contains wrong Method");
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:27,代码来源:DefaultMixologistTest.java

示例3: createTestCases

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

示例4: updateInfo

import gherkin.ast.Step; //导入依赖的package包/类
private TestCase updateInfo(TestCase tc, Step step) {
    if (tc != null) {
        DataItem tcInfo = pModel().getData().find(tc.getName(), tc.getScenario().getName())
                .orElseGet(() -> {
                    DataItem di = DataItem.createTestCase(tc.getName(), tc.getScenario().getName());
                    pModel().addData(di);
                    return di;
                });

        tcInfo.getAttributes().update(Attribute.create("feature.children.step.line", step.getLocation().getLine()));
        tcInfo.getAttributes().update(Attribute.create("feature.children.step.text", step.getText()));
        tcInfo.getAttributes().update(Attribute.create("feature.children.step.argument", step.getArgument()));
        tcInfo.getAttributes().update(Attribute.create("feature.children.step.keyword", step.getKeyword()));
        pModel().addData(tcInfo);
    }
    return tc;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:18,代码来源:BddParser.java

示例5: convertGherkinStepsToCucableSteps

import gherkin.ast.Step; //导入依赖的package包/类
/**
 * Converts a list of Gherkin steps to Cucable steps including data tables.
 *
 * @param gherkinSteps a {@link Step} list.
 * @return a {@link com.trivago.rta.vo.Step} list.
 */
List<com.trivago.rta.vo.Step> convertGherkinStepsToCucableSteps(final List<Step> gherkinSteps) {
    List<com.trivago.rta.vo.Step> steps = new ArrayList<>();

    for (Step gherkinStep : gherkinSteps) {
        com.trivago.rta.vo.Step step;
        com.trivago.rta.vo.DataTable dataTable = null;

        Node argument = gherkinStep.getArgument();
        if (argument instanceof DataTable) {
            dataTable = convertGherkinDataTableToCucumberDataTable((DataTable) argument);
        }

        String keywordAndName = gherkinStep.getKeyword().concat(gherkinStep.getText());
        step = new com.trivago.rta.vo.Step(keywordAndName, dataTable);
        steps.add(step);
    }
    return steps;
}
 
开发者ID:trivago,项目名称:cucable-plugin,代码行数:25,代码来源:GherkinToCucableConverter.java

示例6: convertGherkinStepsToCucableStepsTest

import gherkin.ast.Step; //导入依赖的package包/类
@Test
public void convertGherkinStepsToCucableStepsTest() {
    List<Step> gherkinSteps = Arrays.asList(
            new Step(new Location(1, 1),
                    "Given ", "this is a test step", null),
            new Step(new Location(2, 1),
                    "Then ", "I get a test result", null)
    );

    List<com.trivago.rta.vo.Step> steps = gherkinToCucableConverter.convertGherkinStepsToCucableSteps(gherkinSteps);
    assertThat(steps.size(), is(gherkinSteps.size()));
    com.trivago.rta.vo.Step firstStep = steps.get(0);
    assertThat(firstStep.getName(), is("Given this is a test step"));
    com.trivago.rta.vo.Step secondStep = steps.get(1);
    assertThat(secondStep.getName(), is("Then I get a test result"));
}
 
开发者ID:trivago,项目名称:cucable-plugin,代码行数:17,代码来源:GherkinToCucableConverterTest.java

示例7: stepFailed

import gherkin.ast.Step; //导入依赖的package包/类
@Override
public void stepFailed(Step s, Throwable t) {
    // The additional " " is expected
    if (!"When ".equals(s.getKeyword())) {
        if (CommandLineOptions.hasOption("error")) {
            StringWriter errors = new StringWriter();
            t.printStackTrace(new PrintWriter(errors));
            reporter.report("    Step " + s.getText() + " " + Style.red("failed") + ":\n"
                    + errors.toString());
        }
        else {
            reporter.report("    Step " + s.getText() + " " + Style.red("failed")
                    + ":    \n" + t.getMessage());
        }
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:17,代码来源:TestCommand.java

示例8: concreteScenario

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

示例9: concreteStep

import gherkin.ast.Step; //导入依赖的package包/类
private Step concreteStep(Step abstractStep, Map<String, String> parameters)
{
    String text = abstractStep.getText();

    for (Entry<String, String> entry : parameters.entrySet())
    {
        String target = String.format("<%s>", entry.getKey());
        String replacement = entry.getValue();

        text = text.replace(target, replacement);
    }

    return new Step(
            abstractStep.getLocation(),
            abstractStep.getKeyword(),
            text,
            abstractStep.getArgument());
}
 
开发者ID:mauriciotogneri,项目名称:green-coffee,代码行数:19,代码来源:GreenCoffeeConfig.java

示例10: processStep

import gherkin.ast.Step; //导入依赖的package包/类
private void processStep(Step step, List<StepDefinition> stepDefinitions)
{
    String keyword = step.getKeyword().trim();
    String text = step.getText().trim();
    Node argument = step.getArgument();

    testLog.logStep(keyword, text);

    for (StepDefinition stepDefinition : stepDefinitions)
    {
        if (stepDefinition.matches(text))
        {
            stepDefinition.invoke(text, argument);
            return;
        }
    }

    throw new StepDefinitionNotFoundException(keyword, text);
}
 
开发者ID:mauriciotogneri,项目名称:green-coffee,代码行数:20,代码来源:GreenCoffeeTest.java

示例11: execute

import gherkin.ast.Step; //导入依赖的package包/类
public void execute() throws InvocationTargetException, IllegalAccessException {
	assertNotInterrupted();
	try {
		Martini martini = martiniResult.getMartini();
		Map<Step, StepImplementation> stepIndex = martini.getStepIndex();
		martiniResult.setStartTimestamp(System.currentTimeMillis());

		DefaultStepResult lastResult = null;
		for (Map.Entry<Step, StepImplementation> mapEntry : stepIndex.entrySet()) {
			assertNotInterrupted();
			Step step = mapEntry.getKey();
			eventManager.publishBeforeStep(this, martiniResult);

			StepImplementation implementation = mapEntry.getValue();
			if (null == lastResult || Status.PASSED == lastResult.getStatus()) {
				lastResult = execute(step, implementation);
			}
			else {
				lastResult = new DefaultStepResult(step, implementation);
				lastResult.setStatus(Status.SKIPPED);
			}
			martiniResult.add(lastResult);
			eventManager.publishAfterStep(this, martiniResult);
		}
	}
	finally {
		martiniResult.setEndTimestamp(System.currentTimeMillis());
	}
}
 
开发者ID:qas-guru,项目名称:martini-jmeter-extension,代码行数:30,代码来源:MartiniSamplerClient.java

示例12: translate

import gherkin.ast.Step; //导入依赖的package包/类
@Override
public SpecflowFileContents translate(List<ScenarioDefinition> scenarios, List<Tag> tags, ITestFrameworkConstants constants) {
    String featureContent = scenarios.stream()
            .map( scenario -> {
                String stepsString = scenario.getSteps().stream()
                        .map( step -> String.format(StepBody, step.getKeyword(), step.getText()) )
                        .collect( Collectors.joining( System.getProperty("line.separator")) );
                String tagsString = tags.stream()
                        .map(tg -> String.format("\"%1$s\"", tg.getName()))
                        .collect(Collectors.joining(","));
                return String.format(ScenarioBody,
                        constants.getTestScenarioMethodHeader(scenario.getName()),
                        scenario.getName().replaceAll("[^A-Za-z0-9]", ""),
                        scenario.getName(),
                        tagsString,
                        stepsString);
            })
            .collect( Collectors.joining( System.getProperty("line.separator")) );
    List<Step> stepsDone= new ArrayList<>();
    String stepString = scenarios.stream()
            .map(ScenarioDefinition::getSteps)
            .flatMap(List::stream)
            .filter(step -> !stepsDone.stream().anyMatch(stepDone -> step.getText() == stepDone.getText() && step.getKeyword() == stepDone.getKeyword()))
            .peek(step -> stepsDone.add(step))
            .map(step -> String.format(StepsStepsBody,
                    step.getKeyword(),
                    step.getText(),
                    step.getText().replaceAll("[^A-Za-z0-9]", "")))
            .collect( Collectors.joining( System.getProperty("line.separator")) );

    return new SpecflowFileContents(featureContent, stepString);
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:33,代码来源:SpecflowTranslatorCSharp.java

示例13: DefaultMartini

import gherkin.ast.Step; //导入依赖的package包/类
protected DefaultMartini(
	Recipe recipe,
	ImmutableMap<Step, StepImplementation> stepIndex,
	Iterable<DefaultMartiniTag> tags
) {
	this.recipe = recipe;
	this.stepIndex = stepIndex;
	this.tags = ImmutableSet.copyOf(tags);
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:10,代码来源:DefaultMartini.java

示例14: isAnyStepAnnotated

import gherkin.ast.Step; //导入依赖的package包/类
@Override
public boolean isAnyStepAnnotated(Class<? extends Annotation> annotationClass) {
	checkNotNull(annotationClass, "null Class");
	Map<Step, StepImplementation> index = getStepIndex();

	boolean evaluation = false;
	Iterator<Map.Entry<Step, StepImplementation>> i = index.entrySet().iterator();
	while (!evaluation && i.hasNext()) {
		Map.Entry<Step, StepImplementation> mapEntry = i.next();
		StepImplementation implementation = mapEntry.getValue();
		Method method = implementation.getMethod();
		evaluation = null != method && method.isAnnotationPresent(annotationClass);
	}
	return evaluation;
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:16,代码来源:DefaultMartini.java

示例15: getMartinis

import gherkin.ast.Step; //导入依赖的package包/类
@Override
public ImmutableList<Martini> getMartinis() {
	synchronized (martinisReference) {
		ImmutableList<Martini> martinis = martinisReference.get();
		if (null == martinis) {
			Map<String, StepImplementation> index = context.getBeansOfType(StepImplementation.class);
			Collection<StepImplementation> implementations = index.values();

			ImmutableList.Builder<Martini> builder = ImmutableList.builder();
			for (Recipe recipe : recipes) {
				DefaultMartini.Builder martiniBuilder = DefaultMartini.builder().setRecipe(recipe);
				Pickle pickle = recipe.getPickle();
				Background background = recipe.getBackground();
				ScenarioDefinition scenarioDefinition = recipe.getScenarioDefinition();
				List<PickleStep> steps = pickle.getSteps();
				for (PickleStep step : steps) {
					Step gherkinStep = getGherkinStep(background, scenarioDefinition, step);
					StepImplementation implementation = getImplementation(gherkinStep, implementations);
					martiniBuilder.add(gherkinStep, implementation);
				}
				Martini martini = martiniBuilder.build();
				builder.add(martini);
			}
			martinis = builder.build();
			martinisReference.set(martinis);
		}
		return martinis;
	}
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:30,代码来源:DefaultMixologist.java


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