Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cucumber功能文件未标识这些步骤_Java_Eclipse_Selenium_Cucumber_Gherkin - Fatal编程技术网

Java Cucumber功能文件未标识这些步骤

Java Cucumber功能文件未标识这些步骤,java,eclipse,selenium,cucumber,gherkin,Java,Eclipse,Selenium,Cucumber,Gherkin,我已经写了我的firsy Cumber特性文件。当我将功能文件作为Cucumber功能运行时,会出现以下错误 “警告:Cucumber JVM的--format选项已被弃用。请改用--plugin。”-我在runner类的@CucumberOptions中使用了“plugin”,但仍然得到相同的错误 2.它说我没有任何场景和步骤 功能:验证模块化GUI页面 场景:验证登录页面#C:/Selenium/RegressionTest/ModularRegression/src/GUI/feature

我已经写了我的firsy Cumber特性文件。当我将功能文件作为Cucumber功能运行时,会出现以下错误

  • “警告:Cucumber JVM的--format选项已被弃用。请改用--plugin。”-我在runner类的@CucumberOptions中使用了“plugin”,但仍然得到相同的错误
  • 2.它说我没有任何场景和步骤 功能:验证模块化GUI页面

    场景:验证登录页面#C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate。功能:3 给定:模块化GUI已打开 何时:验证登录页面 然后:登录模块

    0场景 0步

  • 我没有得到我的步骤片段
  • 我已将以下jar添加到库中

    这是我的跑步课, 软件包图形用户界面

    import org.junit.runner.RunWith;
    
    import cucumber.api.CucumberOptions;
    import cucumber.api.junit.Cucumber;
    
    @RunWith(Cucumber.class)
    @CucumberOptions(
            format = {"pretty", "json:target/"},
            features = {"src/GUI/"}
            )
    public class GUIRunner {
    
    }
    
    这是我的功能文件

    Feature: Validate Modular GUI pages
    
      Scenario: Validate Login Page
        Given: Modular GUI is opened
        When: Validate the login page
        Then: Login to the Modular
    
    如果有人能指出我的代码中缺少什么,我将不胜感激

    多谢各位

    [已编辑] 这是实际错误:

    警告:JVM的--format选项已弃用。请使用 --而不是插件。功能:验证模块化GUI页面

    场景:验证登录页面# C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate。功能:3 给定:模块化GUI已打开 何时:验证登录页面 然后:登录模块

    0场景0步骤0m0.000s


    类路径中缺少要素文件

    你没告诉我们你是怎么跑的。但是,如果您将它作为Maven构建的一部分运行(这是比较容易的选项之一),那么您希望将您的功能文件存储在

    ./src/test/resources/GUI

    一个简单的入门方法是从GitHub下载入门项目

    它将为您提供一个工作项目,您可以修改该项目以包含您的问题。

    我在我的功能文件中有一个额外的“:”在给定之后,何时,然后


    它正在工作。

    步骤定义在哪里?尝试添加标签“胶水”,如下所示

    @RunWith(Cucumber.class)
    @CucumberOptions(
            format = {"pretty", "json:target/"},
            features = {"src/GUI/"},
            glue = {"path/to/steps"} 
            )
    public class GUIRunner {
    
    }
    

    只是为了补充现有的答案:在编写步骤的实际代码之前,请记住编写“Scenario:”。这可能看起来非常琐碎,但如果没有它,您将始终收到“0个功能,0个步骤”的消息


    来源:

    请在
    @cucucumberoptions()中添加
    标签={@SmokeTest}
    标签={@RegresionTest}
    请在
    @cucucumberoptions()中添加
    标签={@SmokeTest',“@reg退测试”}

    格式替换为插件,因为格式选项在2014年10月30日从v1.2.0版起被弃用。下面的例子-

    @RunWith(Cucumber.class)
    @CucumberOptions(features = "classpath:features/functional/",
                         glue = {"com.jacksparrow.automation.steps_definitions.functional" },
                       plugin = { "pretty","json:target/cucumber-json/cucumber.json",
                                "junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
                       tags = { "@BAMS_Submitted_State_Guest_User" },
                       strict = false,
                       dryRun = false,
                   monochrome = true)
    

    谢谢@Thomas Sundberg我不使用Maven,我只是使用空项目构建它。我没有收到youtube海报的反馈谢谢你的时间。目前我的功能文件位于src\GUI\features,我也尝试了你提到的位置。我还是有同样的问题