2

I am trying to run a simple example of cucumber-Junit in Intellij, but not geting error "Test ignored". (I have installed cucumber for Java plugin)

My feature file, Runner class, Stepdefinition class and java class look as below:

Java Class

StepDeifinition

Runner class

Feature File

pom.xml

I also tried to restructure the stepdefinition and feature file in multiple ways but it did not help.

1) Does the error mean, it is not finding stepdefinition file (Feature1Steps.java) ? if yes, how do I make it find it ?

2) I am not able to run feature file (Feature1.feature) either. It says : "Test Framework quit unexpectedly"

3) I have tried 1) and 2) with both the latest Cucumber for Java plugin and an older one (183.4284.148). But that did not solve the issue.

Could someone please help me here ?

user523956
  • 501
  • 2
  • 9
  • 23

2 Answers2

1

Well, I did change multiple things and would like to post it here..

1) The words in scenario in feature file and step definition file are case sensitive so I corrected it. (in feature file when I write "Given that I have a Calculator", then in step definition file also I should write ( @Given("^that I have a Calculator$")). Earlier I had small c (calculator) in first step of my step definition file.

2) I just put stepdefinition file and Runnerclass files in the same package and feature file in resources folder. see screenshot below: enter image description here

After having this structure I do not require to specify glue at all in Cucumber options in Runner class. I just require to specify where my feature file exists. see below:

enter image description here

3) now I am using cucumber version 4.2.0. But that did not make any difference I think.

enter image description here

I hope this helps others.

user523956
  • 501
  • 2
  • 9
  • 23
0

Move the .feature file to resources/com/example.

From the Cucumber docs:

"If Cucumber is telling you that your steps are undefined, when you have defined step definitions, this means that Cucumber cannot find your step definitions. You’ll need to make sure to specify the path to your step definitions (glue path) correctly.

By default Cucumber-JVM will search in the package (or sub-packages) of the runner class. You can also tell Cucumber-JVM explicitly which packages (and sub-packages) to search, with:

 @CucumberOptions(glue = {"<package>", "<package>", "<etc>"})
 public class RunCucumberTest{}"

"

(Sidenote: you are using a very old version of Cucumber. v5 is about to be released.)

Marit
  • 2,399
  • 18
  • 27
  • Hi Marit, I updated my pom.xml to take LATEST version. Also I deleted feature file path, GLue n also both. But getting the same error.. – user523956 Oct 31 '19 at 09:29
  • did you move your .feature file? – Marit Oct 31 '19 at 09:31
  • yes I did move it to resources/com/example and changed the pah accordingly. It is finding feature file but again giving error "Test ignored"! Perhaps it has to do with the cucumber for java plugin ? I tried to uninstall and install it again but did not help. – user523956 Oct 31 '19 at 09:41
  • How are you running your tests? – Marit Oct 31 '19 at 09:42
  • I just run the Runner class i.e. RunCalculator.java from IntelliJ run button. One more thing I tried giving wrong path to glue thinking it would complain abt wrong path or it does not exist etc. But it does not complain like that. So I guess it is just not trying to find glue anywhere ? I wrote @CucumberOptions( features = "src/test/resources/com/example", glue = {"com.example1"} ) – user523956 Oct 31 '19 at 09:45
  • You might need to add your glue location to your run configuation in IntelliJ. Alternatively see what happens if you try running `mvn clean install`? – Marit Oct 31 '19 at 09:46
  • where exactly should I specify Glue in Edit Run configuration ? just for info I am using Bundeled Maven in IntelliJ. Hopw that does not make any difference here..Maven clean install shows : Results : Tests run: 5, Failures: 0, Errors: 0, Skipped: 4 and then Build Success.. Why Test run 5 ? I m wondering... – user523956 Oct 31 '19 at 09:50