IntelliJ IDEA not recognizing .feature files

前端 未结 8 654
走了就别回头了
走了就别回头了 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

    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>1.2.5</version>
    </dependency>
    

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

    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>4.6.0</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-02 07:44

    I had the same issue: Substeps not enabled in my IDE... soooo:

    Check if you have garbage .feature of former Files in your File Types patterns. Somehow i had two feature files under the text-Format File Type... that caused new feature files not being recognized as such on creation.

    I think this happens if you do not mark files as feature-files on creation and do this afterwards with refactoring. Then intelliJ saves the pattern of the feature-file under text-type...

    0 讨论(0)
提交回复
热议问题