即使在更新新路径后也会使用旧的要素文件路径

问题描述 投票:-1回答:1

我是黄瓜的新手,我正在自动化一个场景。最初我将我的功能文件保存在路径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)

eclipse selenium cucumber bdd cucumber-jvm
1个回答
0
投票

您需要注意以下几点:

  • 根据Best Practices cerate目录features将严格通过你的featurefile(s)包含IDE(不是通过其他软件NotepadTextpadSubLime3),如下图所示(New - > File):

CO_Self_Service_Home_Page_Personalizations

  • featurefile目录中严格通过你的CO_Self_Service_Home_Page_Personalizations.feature创建featuresIDE
  • 通过将包含特征文件的目录放在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文件必须与下图中的类似层次结构:

Cucumber_Project_Structure

  • 所以你的CucumberOptions将如下: @CucumberOptions(features = {"features" }, glue = {"StepDefinitions" })
  • 执行你的Test

注意:不要move / copy功能file(s) / directory(ies)。仅通过IDE删除不需要的和create

© www.soinside.com 2019 - 2024. All rights reserved.