我是黄瓜新手,我正在自动化一个场景。最初我将我的功能文件保存在路径C:\ Users \ test \ eclipse-workspace \ Automation \ src \ test \ resources \ featureFile中。然后我将功能文件移动到另一个路径(C:\ Users \ test \ eclipse-workspace \ Automation \ src \ test \ com \ test] automation \ features)。我在CucumberOptions中更新了相同内容,如下所示。
@CucumberOptions(features = {
"src/test/java/com/test/automation/features/CO_Self_Service_Home_Page_Personalizations.feature" }, glue = {
"src/test/java/com/oracle/peoplesoft/HCM/StepDefinitions" })
但是当我尝试运行该功能时,我收到以下异常,说明找不到功能文件。这里异常中显示的路径是旧路径。由于我更新了Cucumber选项中的新路径,因此我不确定它的获取位置。能否帮助我理解这个问题的原因。
线程“main”中的异常java.lang.IllegalArgumentException:不是 文件或目录: C:\ Users \用户测试\ Eclipse的工作空间\自动化\ SRC \测试\资源\ featureFile \ Self_Service_Home_Page_Personalizations.feature 在 cucumber.runtime.io.FileResourceIterator $ FileIterator。(FileResourceIterator.java:54) 在 cucumber.runtime.io.FileResourceIterator。(FileResourceIterator.java:20) 在 cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19) 在 cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:103) 在 cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54) 在 cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34) 在 cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235) 在cucumber.runtime.Runtime.run(Runtime.java:110)at cucumber.api.cli.Main.run(Main.java:36)at cucumber.api.cli.Main.main(Main.java:18)
答案 0 :(得分:0)
您需要注意以下几点:
Best Practices
严格通过您的 {{1}清除目录 features
,其中包含 featurefile(s)
根据下图(IDE
- > Notepad
),仅限(不通过其他软件Textpad
或SubLime3
或New
)) :File
在 featurefile
目录中创建CO_Self_Service_Home_Page_Personalizations.feature
即 features
强>只有。将 IDE
置于 Project Structure
下的目录中,以保持您的 Project Workspace
简单。对于Featurefiles
,Cucumber使用目录名称。因此,在项目空间自动化(与 src 相同的层次结构)下创建功能目录。因此 Self_Service_Home_Page_Personalizations.feature
的位置为:
C:\Users\test\eclipse-workspace\Automation\features\Self_Service_Home_Page_Personalizations.feature
同样,您在{strong> Class
的@CucumberOptions
文件中提到 glue = {"StepDefinitions" }
,确保{{ 1}}包含 Class
的文件必须与下图类似:
所以 @CucumberOptions
将如下所示:
CucumberOptions
执行 @CucumberOptions(features = {"features" }, glue = {"StepDefinitions" })
注意:请勿
Test
/move
功能copy
/file(s)
。 仅通过 IDE 删除不需要的directory(ies)
新。