gpt4 book ai didi

testing - Cucumber Feature 文件看不到 "step"文件

转载 作者:行者123 更新时间:2023-11-28 20:37:29 25 4
gpt4 key购买 nike

这只是我使用 Cucumber 的第二天。我已经创建了测试文件和步骤文件。 Cucumber 启动并运行,但它继续告诉我编写步骤文件。这些文件是否有命名约定,或者我是否需要以某种方式指向步骤文件?我正在尝试学习教程。

谢谢

cucumber :版本 3.1.0

Ruby 版本:2.4.1p111(2017-03-22 修订版 58053)[x86_64-darwin16]

rspec-核心 3.7.1

 test/features/step_definitions/test_step.rb


require 'watir'
require 'colorize'

browser = Watir::Browser.new


Given(/^I am on Guru99 Demo Page$/) do

browser.goto "http://demo.guru99.com"

end


When (/^Enter blank details for login$/)do
browser.text_field(:name,"emailid").set (" ")
browser.button(:name,"btnLogin").click
end

Then (/^Show error message$/)do
puts 'Email is Required!'.red
browser.close
end

还有我的测试文件:

测试/特征/test.feature

Feature: guru99 Demopage Login
In order to Login in Demopage we have to enter login details


Scenario: Register On Guru99 Demopage without email

Given I am on the Guru99 homepage

When enter blank details for Register

Then error email shown

这是我运行 Cucumber 时控制台中的结果。

ZeroCalms-MacBook-Pro:features ZeroCalm$ cucumber test.feature

Feature: guru99 Demopage Login
In order to Login in Demopage we have to enter login details

Scenario: Register On Guru99 Demopage without email # test.feature:5
Given I am on the Guru99 homepage # test.feature:7
When enter blank details for Register # test.feature:9
Then error email shown # test.feature:11

1 scenario (1 undefined)
3 steps (3 undefined)
0m0.026s

You can implement step definitions for undefined steps with these
snippets:

Given("I am on the Guru{int} homepage") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end

When("enter blank details for Register") do
pending # Write code here that turns the phrase above into concrete
actions
end

Then("error email shown") do
pending # Write code here that turns the phrase above into concrete
actions
end

最佳答案

您应该使步骤定义中的表达式与特征文件中的步骤“完全”匹配。

所以I am on Guru99 Demo Page 在步骤定义上不同于I am on the Guru99 homepage

Enter blank details for login 相同,不同于 enter blank details for Register

Show error message 也一样,不同于error email shown

这就是您获得实现这些步骤定义的建议的原因:

You can implement step definitions for undefined steps with these 
snippets:

Given("I am on the Guru{int} homepage") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end

When("enter blank details for Register") do
pending # Write code here that turns the phrase above into concrete
actions
end

Then("error email shown") do
pending # Write code here that turns the phrase above into concrete
actions
end

因为 Cucumber 找不到。

关于testing - Cucumber Feature 文件看不到 "step"文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48996990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com