使用Java获取黄瓜中未定义的场景和步骤 [英] Getting scenario and steps undefined in cucumber with java
问题描述
自2天以来,我一直在与之抗争.显示我的测试通过了,但是对于Selenium Webdriver测试,该测试未在Cucumber + java中运行.在控制台中,我收到以下消息
I have been battling with this since 2 days. My test is shown passed but the test is not running in cucumber+java for Selenium webdriver test. In the console I am getting following message
1 Scenarios (1 undefined)
4 Steps (4 undefined)
0m0.000s
You can implement missing steps with the snippets below:
@Given("^User navigate to shopping page$")
public void user_navigate_to_shopping_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^user enters data$")
public void user_enters_data() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^clicks on search button$")
public void clicks_on_search_button() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^product should be displayed$")
public void product_should_be_displayed() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
我写了赛跑者课程
package stepDefinition;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome=true,
features = "src/main/resources/feature",
glue="src/test/java/stepDefinition",
tags={"@tag2"},
dryRun = false)
public class TestRunner {
}
我还将附上项目目录结构的屏幕截图
I will also attach the screenshot of directory structure of the project
特征文件是
[![Feature: Checking Functionality
This is a demo test
@tag2
Scenario: Test Login
Given User navigate to shopping page
When user enters data
And clicks on search button
Then product should be displayed
推荐答案
给定胶水值的方法不正确.您必须提供java软件包格式.尝试使用glue = "stepDefinition"
.
The way you have given the value of glue is incorrect. You have to give in java package format. Try glue = "stepDefinition"
instead.
如果您的当前 stepDefinition 包中有一个包,则说出具有代码的 steps .然后胶水变成"stepDefinition.steps"
If you had a package inside your current stepDefinition package lets say steps which has the code. Then glue becomes "stepDefinition.steps"
您应该将功能部件移动到test \ resources文件夹.
You should move your features to the test\resources folder.
这篇关于使用Java获取黄瓜中未定义的场景和步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!