@Before doesn't execute in java Cucumber Step

前端 未结 7 1704
一生所求
一生所求 2021-02-04 06:19

I\'ve got a Cucumber Step class that i\'m attempting to initialise a page model for all scenarios. So I added a @Before annotated method :

@Before()
private void         


        
7条回答
  •  灰色年华
    2021-02-04 06:37

    I know this issue is old, but in case somebody runs into the same problem using IntelliJ:

    Check the "Glue"-Property in your Run/Debug Configuration. This is the list of paths that Glue (the autowirering-system from Cucumber) uses to find Classes to wire.
    It seems like IntelliJ is generating this property, if it is not specifically defined in the the Template for "Cucumber Java"-Configs.

    I don't know how it is generated, but for me the package that contains my class with the Before-Method in question did not exist. After adding it everything worked normally.

    Edit:

    Found out more background-info. The IntelliJ Cucumber Plugin does not use Junit oder TestNG, but his own implemented runner suite. This runner does NOT interepret the Annotation-Based configurations from Cucumber, only the ones from the Cucumber Property-File or System-Properties. The TestNG-Suite however always overwrites the Glue-Path, not matter if it was actually set or is present. The most consistent way I found was to configure it both using annotations and properties. That way you are always sure that you're config ist used (Gradle-Runner, TestNG-Runner, IntellijCucumber-Runner)

提交回复
热议问题