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 have checked to make sure the plugins are enabled in the plugins settings window.feature file in IntelliJ
-
I have the same issue but some project I'm working on, the feature files are automatically recognized while in my project they are not recognized =/ – Akyo Mar 05 '18 at 09:32
12 Answers
Check Settings->Editor->File Types. Verify that Cucumber Scenario is set to a Registered Pattern of *.feature.

- 318
- 1
- 4
-
1This tipped me off to uninstall Substeps which was blocking it from working. – Zeek Aran Sep 25 '18 at 20:43
-
1
If you have Substeps IntelliJ Plugin enabled then that might be the issue. you will need to remove and restart.

- 199
- 2
- 4
-
4Thank you. The other answer here wouldn't have been necessary for me if I didn't have this other plugin blocking me. – Zeek Aran Sep 25 '18 at 20:44
Check File -> Settings -> Editor -> File Types and click on the Text file type. Look at the Registered Patterns section below and verify that the file you're trying to create is not in the list of recognized patterns for Text file types.
This might happen if you created the file without initially giving it the .feature extension. If you do that and then try to add the extension afterwards IntelliJ will probably still think it's a text file and will not treat it as a feature file. This was the fix for me.
If you're seeing IntelliJ recognizing your intended feature file as some other type of file then check the recognized patterns for that file type and verify again that the file you're trying to create is NOT in that list.
See http://www.gisremotesensing.com/2014/11/solution-intellij-not-recognizing.html
For some setups, this is only half the story. Once, you have removed the old file type; now follow the steps:
- Select "Cucumber scenario" in the "Recognized file types"
- In the "Registered patterns" box click the "+" and type "*.feature"
Now you are all set. The feature files will be back to normal.

- 1
- 1

- 101
- 1
- 5
-
In my case I created the file without the ".feature" extension and I fixed it by creating a new file with the ".feature" extension and it fixed it :). – Akyo Mar 05 '18 at 09:34
-
Had the same issue. Uninstalling the 'Substeps IntelliJ Plugin' plugin fixed it for me cause that also registered for .feature files. :) – Florian Baierl Sep 12 '18 at 08:13
-
1
Navigate to the settings from File option at menu then -> Editor -> File Types --> Select Cucumber scenario (Recognized file types ) observe that if Registered patterns has *.feature if not then click on + icon and add *.feature in Registered patterns. Apply changes and save. It solved my problem of .feature file. Thanks!

- 31
- 1
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.cukes
dependency 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>

- 7,267
- 17
- 79
- 129
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...

- 21
- 3
InjelliJ IDEA 2021.1.2
I had my feature filename listed under Settings > Editor > File Types > Auto-Detect file type by content. Removed it and its all working.

- 21
- 3
I had a typo in the file name extension. Easy to miss.
Verify that the feature file name ends with .feature
.

- 1,913
- 19
- 27
For me it was even worse. The .feature extension was assigned to text. Which was odd as previously created .feature files remained real feature files. Yet newly created feature files were seen as plain text. So do check all relevant file types as intelIj does strange things with this.

- 347
- 2
- 7
In my case when I tried to add .feature
file, a prompt came up and I added the file as text. Then Intellij automatically suggested that it found plugins(Gherkin plugin) matching .feature
file. After installing Gherkin
plugin , IntelliJ automatically formatted the file with Gherkin
format

- 3,060
- 6
- 30
- 66
Using IntelliJ IDEA 2022.1.2 (Ultimate Edition)
A quite quick manual patch is to right click on the .feature
file you want to be recognised. A dropdown menu should appear. Click on the "Override File Type" option. Then, scroll down until you find "Gherkin", and select it.

- 27
- 1
- 9
I had a single feature file not being recognised as runable, and others in the same directory were fine.
I fixed this by deleting the .cs file generated for the .feature file, and then rebuilding - that allowed the feature file to then be run as a test. Not sure what was wrong with the 'old' .cs file.

- 83
- 6