cucumber-jvm-groovy
cucumber-jvm-groovy copied to clipboard
Intellij not recognizing these groovy steps
Hi, Are you observing any issue related to Intellij showing steps as Undefined.? I upgraded my cucumber-groovy , cucumber-core & cucumber-junit to 5.1.3 and observing this problem. Earlier I was using cucumber 1.25 and everything was working fine. Any pointers will be great help.
Thanks!
Hello! My company hasn't yet migrated to cucumber-jvm-groovy 5.X just yet, but we are on 4.X. This shows up every now and then for us, and here is what we do to fix this:
- Make sure you have installed the IntelliJ plugins "Cucumber for Java" and "Cucumber for Groovy"
Thanks for the reply. I have both these plugins and I uninstalled 'substeps' plugin as well. Still I face this issue.
Hello! My company hasn't yet migrated to cucumber-jvm-groovy 5.X just yet, but we are on 4.X. This shows up every now and then for us, and here is what we do to fix this:
- Make sure you have installed the IntelliJ plugins "Cucumber for Java", "Cucumber for Groovy", and "Gherkin".
- Open up Project Structure window, go to the Modules left tab, click on your project, click on the sources tab
- Find the folder containing your steps, mark the directory as Test Resources (ours was src/test/groovy/steps)
- Find the folder containing your features, mark the directory as Test Resources (ours was src/test/resources)
- For us, we had to also do the following. These may or may not be required depending on your project setup
- Mark src/test/groovy as Test Sources
- Mark src/main/groovy as Sources
- Mark src/main/java as Sources (if applicable)
- Mark src/main/resources as Resources
- Invalidate caches and restart (if changes didn't already work)
- If after indexing that still did not work, then follow 2-6 again, but first unmark each folder as what was mentioned above and then mark it.
Those are the things that worked for us, hope these help.
@ice1080 : Thanks again. I already tried these steps as we used to work with cucumber 1.25. This is definitely looking like bug in Intellij. I have posted it on other sites as well. Here is the link: https://stackoverflow.com/questions/62956227/intellij-not-able-to-identify-cucumber-5-groovy-steps
@ice1080 : Thanks again. I already tried these steps as we used to work with cucumber 1.25. This is definitely looking like bug in Intellij. I have posted it on other sites as well. Here is the link: https://stackoverflow.com/questions/62956227/intellij-not-able-to-identify-cucumber-5-groovy-steps
Step 7 was the one that worked 90% of the time and definitely the most important of all of the above steps. Unmarking them all and then remarking didn't work?
@ice1080 : Hey after changing cucumber-groovy to 4.7.1 & cucumber-core & cucumber-junit to 4.8.1, I am still facing this issue. which version you are using in your proj ? Dont know if I am missing something very basic. Intellij I am using is 2020.1.3.
@ice1080 : Hey after changing cucumber-groovy to 4.7.1 & cucumber-core & cucumber-junit to 4.8.1, I am still facing this issue. which version you are using in your proj ? Dont know if I am missing something very basic. Intellij I am using is 2020.1.3.
We are using cucumber-groovy, cucumber-junit, and cucumber-spring, all versions 4.5.4, and cucumber-reporting 4.7.0. We had some different, unrelated issues on 4.7+ so went back to 4.2.0 and then were able to get up to 4.5.4
4.7.0
@ice1080 : Hey ! I identified my issue. Thing is I messed up with syntax of Groovy and Java and overlooked the syntax of Groovy steps. After correcting it as mentioned in this project, it worked. I upgraded to cucumber-groovy to 4.7.4 & cucumber-core, cucumber-junit to 4.8.1. It is working as expected. Also tried upgrading to 5.1.3 but it was not working. One breaking issue I observed after moving from 1.2.5 to 4.8.1 is @Field vars used in my Scripts. I am also trying the version you mentioned above. Thanks much buddy 🥇
Probably would go a long way for this project to create a "cucumber-groovy" plugin for IntelliJ-IDEA that would setup the project structure and source folders auto-magically.
Anyone working on this issue? I want to use version 6.1.2 and it still don't work
I noticed that when we use the proposed:
import io.cucumber.groovy.EN this.metaClass.mixin(EN)
IntelliJ don't recognise step, but when we use old solution:
this.metaClass.mixin(cucumber.api.groovy.EN)
IntelliJ recognise steps. Or it recognises because we actually nothing pass to mixin method.
I think the problem lies somewhere in EN class
Hi @cheparsky ,
Have you got a reproducible snippet/project, it'll help us debug the issue you are seeing.
Also please let us know Intellij version together with plugins installed.
Hi, I'm having issues with the parameters in a project test
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testImplementation group: 'junit', name: 'junit', version: '4.12'
//Cucumber
testImplementation group: 'io.cucumber', name:'cucumber-groovy', version: '6.10.4'
testImplementation group: 'io.cucumber', name:'cucumber-junit', version: '6.10.4'
testImplementation group: 'io.cucumber', name:'cucumber-expressions', version: '12.1.1'
Feature File
Feature: Is it Friday yet?
Everybody wants to know when it's Friday
Scenario: Sunday isn't Friday
Given today is "Sunday"
When I ask whether it is Friday yet
Then I should be told "Nope"
Groovy Script
package steps
import static org.junit.Assert.*;
import io.cucumber.groovy.EN
import io.cucumber.groovy.Hooks
metaClass.mixin(EN)
this.metaClass.mixin(Hooks)
Before(){
def today
}
Given("today is {string}") { String string ->
// Write code here that turns the phrase above into concrete actions
today = "input"
}
When("I ask whether it is Friday yet") { ->
// Write code here that turns the phrase above into concrete actions
today = "Nope"
}
Then("I should be told {string}") { String input ->
// Write code here that turns the phrase above into concrete actions
assertEquals(today, input)
}
When I run the test, I have this error:
Any clue about it?
Hi, I'm having issues with the parameters in a project test
compile 'org.codehaus.groovy:groovy-all:2.3.11' testImplementation group: 'junit', name: 'junit', version: '4.12' //Cucumber testImplementation group: 'io.cucumber', name:'cucumber-groovy', version: '6.10.4' testImplementation group: 'io.cucumber', name:'cucumber-junit', version: '6.10.4' testImplementation group: 'io.cucumber', name:'cucumber-expressions', version: '12.1.1'
Feature File Feature: Is it Friday yet? Everybody wants to know when it's Friday Scenario: Sunday isn't Friday Given today is "Sunday" When I ask whether it is Friday yet Then I should be told "Nope"
Groovy Script
package steps import static org.junit.Assert.*; import io.cucumber.groovy.EN import io.cucumber.groovy.Hooks metaClass.mixin(EN) this.metaClass.mixin(Hooks) Before(){ def today } Given("today is {string}") { String string -> // Write code here that turns the phrase above into concrete actions today = "input" } When("I ask whether it is Friday yet") { -> // Write code here that turns the phrase above into concrete actions today = "Nope" } Then("I should be told {string}") { String input -> // Write code here that turns the phrase above into concrete actions assertEquals(today, input) }
When I run the test, I have this error:
Any clue about it?
I have the same problem.But if I add ^$ to the content. It works.
@janainaiacia and @assilzm, when we define our groovy steps we do so like this:
Given(~'^today is "([^"]*)"$') { String input ->
println input
}
The ~ before tells groovy that it's a regex string. The starting ^ and ending $ tell it that there should be no other text in the step. Then the "([^"]*)"
tells it that there is a String parameter in the double quotes.
I'll also mention that we put our cucumber definitions in an implementation block instead of testImplementation. That's primarily because we're using cucumber with selenium and it complains if we don't.
Hopefully that's helpful. Cheers.
Hi @icdt-ihudson , last version 6.10.4 is working fine for me. But I have problem with step definitions; when i use (~'^step$')
all works fine, and when I want use@ParameterType step arguments using ('step')
IntelliJ doesn't recognize it in feature file and stepsDefs are not clickable
Hi @cheparsky. I'm still on version 5.1.3, but unfortunately I've never used the @ParameterType definition so can't help with that. Is there a reason you need that type of step definition instead of using the above format? Not saying it shouldn't work, just wanting to understand it. I'm not a contributor to the project, just a user; but perhaps tagging one of the contributors might get them to figure out what's going on with the @ParameterType?
@icdt-ihudson yes, I need this another format, only this format works with @ParameterType.
@glibas @mpkorstanje do you know smth about this error, can you fix it? Or this problem more related to Intellij itself?
@cheparsky in https://github.com/cucumber/cucumber-jvm-groovy/issues/20#issuecomment-828787780 you were asked to provided a minimal reproducer and additional information. You've not provided that information so it would be hard for anyone to help you.
Anyway, I wouldn't be able to tell you much more, and if I think @glibas is currently fighting in a war. You may have to investigate this in more detail yourself.