cucumber.api.TestStep Java Examples

The following examples show how to use cucumber.api.TestStep. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StepFormatter.java    From akita with Apache License 2.0 6 votes vote down vote up
/**
 * Метод осуществляет снятие скришота и прикрепление его к cucumber отчету.
 * Скриншот снимается после шагов, помеченных аннотацией @Screenshot,
 * либо после каждого шага, если задана системная переменная takeScreenshotAfterSteps=true
 * @param testStep - текущий шаг
 *
 */
private void afterStep(TestStep testStep) {
    String fullMethodLocation = testStep.getCodeLocation();
    String currentMethodName = fullMethodLocation.substring(fullMethodLocation.indexOf('.') + 1, fullMethodLocation.indexOf('('));

    List<Method> methodsWithScreenshotAnnotation = new Reflections(new MethodAnnotationsScanner())
        .getMethodsAnnotatedWith(Screenshot.class)
        .stream()
        .filter(m -> m.getName().contains(currentMethodName))
        .collect(Collectors.toList());

    boolean isScreenshotAnnotationPresent = methodsWithScreenshotAnnotation.size() > 0;

    boolean isTakeScreenshotAfterStepsProperty = System.getProperty(SCREENSHOT_AFTER_STEPS) != null
        ? Boolean.valueOf(System.getProperty(SCREENSHOT_AFTER_STEPS)) : false;

    if (isScreenshotAnnotationPresent || isTakeScreenshotAfterStepsProperty) {
        final byte[] screenshot = ((TakesScreenshot) getWebDriver()).getScreenshotAs(OutputType.BYTES);
        AkitaScenario.getInstance().getScenario().embed(screenshot, "image/png");
    }
}
 
Example #2
Source File: TCKTestCase.java    From openCypher with Apache License 2.0 5 votes vote down vote up
public TCKTestCase(Pickle pickle, List<TestStep> testSteps, String uri, int line) {
    this.name = pickle.getName();
    this.testSteps = testSteps;
    this.tags = pickle.getTags();
    this.uri = uri;
    this.line = line;
}
 
Example #3
Source File: CucumberReportAdapter.java    From openCypher with Apache License 2.0 5 votes vote down vote up
private Consumer<Scenario> scenarioStartedEvent() {
    return scenario -> {
        Long startedAt = time();
        String featureUri = checkNull(featureNameToUri.get(scenario.featureName()));
        Pickle pickle = scenario.source();
        List<TestStep> steps = pickle.getSteps()
            .stream()
            .map(step -> new TCKTestStep(step, featureUri, outlineLocation(step.getLocations())))
            .collect(Collectors.toList());
        int line = outlineLocation(pickle.getLocations());
        currentTestCase = new TCKTestCase(pickle, steps, featureUri, line);
        bus.handle(new TestCaseStarted(startedAt, currentTestCase));
    };
}
 
Example #4
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private String getStepUuid(final TestStep step) {
    return currentFeature.getName() + getTestCaseUuid(currentTestCase)
            + step.getPickleStep().getText() + step.getStepLine();
}
 
Example #5
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private String getHookStepUuid(final TestStep step) {
    return currentFeature.getName() + getTestCaseUuid(currentTestCase)
            + step.getHookType().toString() + step.getCodeLocation();
}
 
Example #6
Source File: TCKTestCase.java    From openCypher with Apache License 2.0 4 votes vote down vote up
@Override
public List<TestStep> getTestSteps() {
    return testSteps;
}