我是黄瓜的新手,我正在自动化一个场景。最初我将我的功能文件保存在路径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:不是文件或目录:在cucumber.runtime.io.FileResourceIterator中的C:\ Users \ test \ eclipse-workspace \ Automation \ src \ test \ resources \ featureFile \ Self_Service_Home_Page_Personalizations.feature $ FileIterator。(FileResourceIterator.java:54)在cucumber.runtime.io.FileResourceIterator。(FileResourceIterator.java:20)处于cucumber.runtime.model的cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19)。黄瓜.Feuntime.model.CucumberFeature.load(CucumberFeature.java:54)位于cucumber.runtime.RuntimeOptions的cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)的CucumberFeature.loadFromFeaturePath(CucumberFeature.java:103) .cucumberFeatures(RuntimeOptions.java:235)位于cucumber.apun.cli.Mun.run(Main.java:36)的cucumber.runtime.Runtime.run(Runtime.java:110)黄瓜.api.cli.Main。主(Main.java:18)
您需要注意以下几点:
Best Practices
cerate目录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使用目录名称。因此,在项目空间Automation(与src相同的层次结构)下创建features目录。所以Self_Service_Home_Page_Personalizations.feature
的位置将是:
C:\Users\test\eclipse-workspace\Automation\features\Self_Service_Home_Page_Personalizations.feature
Class
的@CucumberOptions
文件中,您提到glue = {"StepDefinitions" }
确保包含Class
的@CucumberOptions
文件必须与下图中的类似层次结构:CucumberOptions
将如下:
@CucumberOptions(features = {"features" }, glue = {"StepDefinitions" })
Test
注意:不要
move
/copy
功能file(s)
/directory(ies)
。仅通过IDE删除不需要的和create
。