0

I downloaded the latest Cucumber Java version - 4.7.2, and am ale to run the cucumber test from IDE Intellij, everything is fine in IDE. However, if run from command line then it gives me error "io.cucumber.junit.UndefinedThrowable:"

Run test runner "RunCucumberTest" in IDE: OK

Cucumber-jvm Approach:

java -cp "lib/cucumber-4.7.2/*" io.cucumber.core.cli.Main --glue au.com.demo.quality.stepdefinitions  --plugin pretty  --name "^demo test$" src/test/resources/features/DemoTest.feature

result: step undefined as above

JUnit Approach:

java -cp "../lib/cucumber-4.7.2/*;../out/production/demo" org.junit.runner.JUnitCore au.com.demo.quality.runners.RunCucumberTest

result: step undefined as above

Project structure:

Quality
-lib
-out
 --Production
   ---demo
   ......
-bdd
 --src
   ---test
      ----java
      ----resources

More details as shown in the screenshot below.

the cucumber structure

I have searched in stackoverflow and google searched as well, no answer found. Useful refereces here but they are not my answer. Thanks.

https://github.com/cucumber/cucumber-jvm/issues/1127#issuecomment-303486249

Cucumber cannot find StepDefinitions while running the code but manually using the option "Find Step" can find step definition

How to run cucumber file from command line

https://www.toolsqa.com/cucumber/cucumber-options/

Jeffgg
  • 21
  • 2
  • 1
    Are you including your own code on the class path? – M.P. Korstanje Sep 11 '19 at 13:05
  • Yes, the classpath 'lib/cucumber-4.7.2/*" is for the required jar packages, there is an old cucumber java 1.2.5 installed in the classpath "lib/", so I moved all new version to "lib/cucumber-4.7.2/*", the other one is for the class file "RunCucumberTest.class". – Jeffgg Sep 11 '19 at 23:26

1 Answers1

2

I figured it out. The step definition class is not able to extend another class, otherwise the step definitions wont be found.

Jeffgg
  • 21
  • 2