IntelliJ IDEA not recognizing .feature files

前端 未结 8 772
走了就别回头了
走了就别回头了 2021-01-02 07:12

I have installed the cucumber-java and gherkin plugins in IntelliJ IDEA but when I create a .feature file it is not recognized as a feature file. I did restart IntelliJ and

8条回答
  •  孤城傲影
    2021-01-02 07:40

    The root cause for this problem is Cucumber-Java plugin looking for BDD annotations that are imported from the package cucumber.api.java.en.Given (depricated) in StepDefinitions file. If the StepDefinitions file consists of BDD annotations from the package io.cucumber.java.en.Given the feature file won't recognize/highlight those steps. This issue is nowhere related to Intellij Version.

    Temporary solution

    Change your import statement in your StepDefinitions file from import io.cucumber.java.en.Given; to import cucumber.api.java.en.Given; Apply the same to When, Then and But unless if you don't mind using deprecated methods ;)

    Note

    If you use the info.cukesdependency you won't have any problem with the cucumber-java plugin

    
      info.cukes
      cucumber-java
      1.2.5
    
    

    You need to use the Temporary Solution if you have the io.cucumber dependency

    
      io.cucumber
      cucumber-java
      4.6.0
    
    

提交回复
热议问题