I have installed: ruby, watir-webdriver, rspec, cucumber.
我安装了:ruby,watir-webdriver,rspec,黄瓜。
I made the folder called "features". There is cucumber test "process.feature" inside it where is one feature with 1 simple scenario. There is also folder called "step_definitions" inside "features" where is ruby file process.rb. I try to run the test writing "cucumber process.feature" into the command line, but it says that steps are undefined: 1 scenario (1 undefined), 3 steps (3 undefined).
我创建了名为“features”的文件夹。里面有黄瓜测试“process.feature”,其中一个特征是1个简单的场景。在“features”中还有一个名为“step_definitions”的文件夹,其中是ruby文件process.rb。我尝试在命令行中运行测试“cucumber process.feature”,但它表示步骤未定义:1个场景(1个未定义),3个步骤(3个未定义)。
Could you please tell me what I am missing?
你能告诉我我错过了什么吗?
process.feature:
Feature:
‘User Login.’
Scenario:
Given I am logged in
When I open the process page
Then I see the details page
process.rb
Given /^I am logged in$/ do
b = Watir::Browser.new
b.goto 'http://star.teepub:000/star-web/'
code = '48702'
password = 'test'
b.text_field(:id => 'j_username').set code
b.text_field(:id => 'j_password').set password
b.link(:id => 'loginBtn').click
end
When /^I open the process page$/ do
pending
end
Then /^I see the details page$/ do
pending
end
1 个解决方案
#1
3
Your structure looks like:
您的结构如下:
--/features
process.feature
---/step_definitions
process.rb
To run this feature type in command line:
要在命令行中运行此要素类型:
cucumber process.feature -r step_definitions
Notice, that to run this command you have to be in feature directory. After command
请注意,要运行此命令,您必须位于功能目录中。命令后
cucumber
you must type path to *.feature file, for example
例如,您必须键入* .feature文件的路径
cucumber features/process.feature
or
cucumber my_project/features/process.feature
Also you can use tags, for example
例如,您也可以使用标签
@some_name
Feature:
‘User Login.’
Scenario:
Given I am logged in
When I open the process page
Then I see the details page
Use command
cucumber --tag @some_name
In this case features, which are tagged with @same_name, will be executed. If you place tag before Scenario and type command
在这种情况下,将执行使用@same_name标记的功能。如果在Scenario之前放置标记并键入命令
cucumber --tag @some_name
again, only scenario tagged with @some_name will be executed.
同样,只会执行使用@some_name标记的方案。
#1
3
Your structure looks like:
您的结构如下:
--/features
process.feature
---/step_definitions
process.rb
To run this feature type in command line:
要在命令行中运行此要素类型:
cucumber process.feature -r step_definitions
Notice, that to run this command you have to be in feature directory. After command
请注意,要运行此命令,您必须位于功能目录中。命令后
cucumber
you must type path to *.feature file, for example
例如,您必须键入* .feature文件的路径
cucumber features/process.feature
or
cucumber my_project/features/process.feature
Also you can use tags, for example
例如,您也可以使用标签
@some_name
Feature:
‘User Login.’
Scenario:
Given I am logged in
When I open the process page
Then I see the details page
Use command
cucumber --tag @some_name
In this case features, which are tagged with @same_name, will be executed. If you place tag before Scenario and type command
在这种情况下,将执行使用@same_name标记的功能。如果在Scenario之前放置标记并键入命令
cucumber --tag @some_name
again, only scenario tagged with @some_name will be executed.
同样,只会执行使用@some_name标记的方案。