黄瓜从命令行运行时找不到StepDefinitions

时间:2019-09-11 05:52:52

标签: java junit cucumber

我下载了最新的Cucumber Java版本-4.7.2,并且可以从IDE Intellij运行黄瓜测试,在IDE中一切正常。但是,如果从命令行运行,则会给我错误“ io.cucumber.junit.UndefinedThrowable:”

在IDE中运行测试运行程序“ RunCucumberTest”:确定

黄瓜jvm方法:

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

结果:步骤如上未定义

JUnit方法:

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

结果:步骤如上未定义

项目结构:

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

更多详细信息,如下面的屏幕截图所示。

the cucumber structure

我已经在stackoverflow中进行了搜索,谷歌也进行了搜索,未找到答案。这里有用的裁判,但不是我的答案。谢谢。

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/

1 个答案:

答案 0 :(得分:0)

我知道了。步骤定义类不能扩展其他类,否则将找不到步骤定义。