Search in sources :

Example 1 with HookTestStep

use of io.cucumber.plugin.event.HookTestStep in project cucumber-jvm by cucumber.

the class TeamCityPlugin method extractName.

private String extractName(TestStep step) {
    if (step instanceof PickleStepTestStep) {
        PickleStepTestStep pickleStepTestStep = (PickleStepTestStep) step;
        return pickleStepTestStep.getStep().getText();
    }
    if (step instanceof HookTestStep) {
        HookTestStep hook = (HookTestStep) step;
        HookType hookType = hook.getHookType();
        switch(hookType) {
            case BEFORE:
                return "Before";
            case AFTER:
                return "After";
            case BEFORE_STEP:
                return "BeforeStep";
            case AFTER_STEP:
                return "AfterStep";
            default:
                return hookType.name().toLowerCase(Locale.US);
        }
    }
    return "Unknown step";
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) HookTestStep(io.cucumber.plugin.event.HookTestStep) HookType(io.cucumber.plugin.event.HookType)

Example 2 with HookTestStep

use of io.cucumber.plugin.event.HookTestStep in project cucumber-jvm by cucumber.

the class JsonFormatter method handleTestStepStarted.

@SuppressWarnings("unchecked")
private void handleTestStepStarted(TestStepStarted event) {
    if (event.getTestStep() instanceof PickleStepTestStep) {
        PickleStepTestStep testStep = (PickleStepTestStep) event.getTestStep();
        if (isFirstStepAfterBackground(testStep)) {
            currentElementMap = currentTestCaseMap;
            currentStepsList = (List<Map<String, Object>>) currentElementMap.get("steps");
        }
        currentStepOrHookMap = createTestStep(testStep);
        // add beforeSteps list to current step
        if (currentBeforeStepHookList.containsKey(before)) {
            currentStepOrHookMap.put(before, currentBeforeStepHookList.get(before));
            currentBeforeStepHookList.clear();
        }
        currentStepsList.add(currentStepOrHookMap);
    } else if (event.getTestStep() instanceof HookTestStep) {
        HookTestStep hookTestStep = (HookTestStep) event.getTestStep();
        currentStepOrHookMap = createHookStep(hookTestStep);
        addHookStepToTestCaseMap(currentStepOrHookMap, hookTestStep.getHookType());
    } else {
        throw new IllegalStateException();
    }
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) HookTestStep(io.cucumber.plugin.event.HookTestStep) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

HookTestStep (io.cucumber.plugin.event.HookTestStep)2 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)2 HookType (io.cucumber.plugin.event.HookType)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1