We have feature files that have long tests that validate multiple things written in non-english language, the Given -> When -> Then
structure doesn't make sense.
I tried replacing feature file keywords with *
, and that works just fine, however here are the problems:
* Some step
, and using Alt->Enter shortcut to generate a step definition, IntelliJ IDEA does... Nothing. It only opens the file where I wanted to put the definition without any added code. I've updated IDE and plugins to be latest.Given
, When
, Then
, And
, But
exists. It's not very logical to have a * Some step
feature and @Given("Some step")
definition.Is there any workaround that I might use?
I think you can achieve this with few coding steps.
Feature: Generic annotation
Scenario: Testing annotations
* having asterix
* use custom generic annotation
package click.webelement.cucumber;
import io.cucumber.java.StepDefinitionAnnotation;
import io.cucumber.java.StepDefinitionAnnotations;
import org.apiguardian.api.API;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@StepDefinitionAnnotation
@Documented
@Repeatable(MyStep.MySteps.class)
@API(status = API.Status.STABLE)
public @interface MyStep {
String value();
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@StepDefinitionAnnotations
@Documented
@interface MySteps {
MyStep[] value();
}
}
package click.webelement.cucumber;
public class StepDef {
@MyStep("having asterix")
public void doOne(){
System.out.println("Running having asterix");
}
@MyStep("use custom generic annotation")
public void doTwo(){
System.out.println("Running use custom generic annotation");
}
}
UPD
In order to make your Idea plugin work with your custom annotation you need to place that annotation to
io.cucumber.java.LANG
package where LANG is the sub-package for your chosen language.
To make everything work as default you place it to
io.cucumber.java.en