Cucumber 特征文件不识别步骤
Cucumber feature file does not identify the steps
我已经编写了我的第一个黄瓜功能文件。当我 运行 特征文件作为 Cucumber 特征时,出现以下错误
- "WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead." - 我在 运行ner class 的 @CucumberOptions 中使用了 "plugin",但仍然出现相同的错误
2.It说我没有任何场景和步骤
功能:验证模块化 GUI 页面
场景:验证登录页面 # C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3
给定:模块化 GUI 已打开
时间:验证登录页面
然后:登录到 Modular
0 个场景
0 步
- 我没有收到我的步数片段。
我已将以下 jar 添加到库中
Jars
这是我的运行小伙伴class,
包 GUI;
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
如果有人能指出我的代码中缺少什么,我将不胜感激。
非常感谢
[编辑]
这是实际错误:
WARNING: Cucumber-JVM's --format option is deprecated. Please use
--plugin instead. Feature: Validate Modular GUI pages
Scenario: Validate Login Page #
C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3
Given: Modular GUI is opened
When: Validate the login page
Then: Login to the Modular
0 Scenarios 0 Steps 0m0.000s
您的 class 路径中缺少您的功能文件。
你不告诉我们你过得如何 运行宁黄瓜。但是如果你想 运行 它作为 Maven 构建的一部分,这是更简单的选项之一,你想将你的功能文件存储在
./src/test/resources/GUI
一种简单的入门方法是从 GitHub、https://github.com/cucumber/cucumber-java-skeleton
下载入门项目
它会给你一个工作项目,你可以修改它来解决你的问题。
在 Given、When 和 Then 之后,我的功能文件中有一个额外的“:”。
现在可以使用了。
您的步骤定义位于何处?尝试像下面这样添加标签 'glue'
@RunWith(Cucumber.class)
@CucumberOptions(
format = {"pretty", "json:target/"},
features = {"src/GUI/"},
glue = {"path/to/steps"}
)
public class GUIRunner {
}
只是添加到现有答案中:记得在编写步骤的实际代码之前写 "Scenario: "。这可能看起来微不足道,但如果没有它,您将始终收到“0 个功能,0 个步骤”的消息。
请加上tags = {"@SmokeTest"}
或tags = {"@RegresionTest"}
请在@CucumberOptions()
中添加tags= {"@SmokeTest","@RegressionTest"}
将 format 替换为 plugin,因为格式选项从 v1.2.0 起已于 2014 年 10 月 30 日弃用。下面的示例 -
@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)
我已经编写了我的第一个黄瓜功能文件。当我 运行 特征文件作为 Cucumber 特征时,出现以下错误
- "WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead." - 我在 运行ner class 的 @CucumberOptions 中使用了 "plugin",但仍然出现相同的错误
2.It说我没有任何场景和步骤 功能:验证模块化 GUI 页面
场景:验证登录页面 # C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 给定:模块化 GUI 已打开 时间:验证登录页面 然后:登录到 Modular
0 个场景 0 步
- 我没有收到我的步数片段。
我已将以下 jar 添加到库中 Jars
这是我的运行小伙伴class, 包 GUI;
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
如果有人能指出我的代码中缺少什么,我将不胜感激。
非常感谢
[编辑] 这是实际错误:
WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead. Feature: Validate Modular GUI pages
Scenario: Validate Login Page # C:/Selenium/RegressionTest/ModularRegression/src/GUI/features/Validate.feature:3 Given: Modular GUI is opened When: Validate the login page Then: Login to the Modular
0 Scenarios 0 Steps 0m0.000s
您的 class 路径中缺少您的功能文件。
你不告诉我们你过得如何 运行宁黄瓜。但是如果你想 运行 它作为 Maven 构建的一部分,这是更简单的选项之一,你想将你的功能文件存储在
./src/test/resources/GUI
一种简单的入门方法是从 GitHub、https://github.com/cucumber/cucumber-java-skeleton
下载入门项目它会给你一个工作项目,你可以修改它来解决你的问题。
在 Given、When 和 Then 之后,我的功能文件中有一个额外的“:”。
现在可以使用了。
您的步骤定义位于何处?尝试像下面这样添加标签 'glue'
@RunWith(Cucumber.class)
@CucumberOptions(
format = {"pretty", "json:target/"},
features = {"src/GUI/"},
glue = {"path/to/steps"}
)
public class GUIRunner {
}
只是添加到现有答案中:记得在编写步骤的实际代码之前写 "Scenario: "。这可能看起来微不足道,但如果没有它,您将始终收到“0 个功能,0 个步骤”的消息。
请加上tags = {"@SmokeTest"}
或tags = {"@RegresionTest"}
请在@CucumberOptions()
tags= {"@SmokeTest","@RegressionTest"}
将 format 替换为 plugin,因为格式选项从 v1.2.0 起已于 2014 年 10 月 30 日弃用。下面的示例 -
@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)