使用黄瓜时遇到一些问题。
这是我的树枝
-- app1
|-- features
| |-- addition.feature
| |-- step_definitions
| `-- support
| `-- env.js
|-- public
| `-- javascripts
| |-- Player.js
| `-- Song.js
|-- Rakefile
`-- spec
`-- javascripts
|-- helpers
| `-- SpecHelper.js
|-- PlayerSpec.js
`-- support
|-- jasmine_config.rb
|-- jasmine_runner.rb
`-- jasmine.yml
这是我的文件“addition.feature”
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When press add
Then the result should be 120 on the screen
当我跑步时
黄瓜特征/添加。特征
我得到了
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers # features/addition.feature:6
Given I have entered 50 into the calculator # features/addition.feature:7
And I have entered 70 into the calculator # features/addition.feature:8
When press add # features/addition.feature:9
Then the result should be 120 on the screen # features/addition.feature:10
1 scenario (1 undefined)
4 steps (4 undefined)
0m0.003s
You can implement step definitions for undefined steps with these snippets:
Given /^I have entered (\d+) into the calculator$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
When /^press add$/ do
pending # express the regexp above with the code you wish you had
end
Then /^the result should be (\d+) on the screen$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
If you want snippets in a different programming language, just make sure a file
with the appropriate file extension exists where cucumber looks for step definitions.
为什么输出是ruby语言,我不应该得到javascript,因为我在“support /”目录中有一个“.js”文件?
答案 0 :(得分:1)
答案 1 :(得分:0)
据我所知,你可以用capybara来测试javascript。快速搜索谷歌:http://openmonkey.com/2010/04/09/javascript-testing-with-cucumber-capybara/
答案 2 :(得分:0)
您可能对Cucumber.js感兴趣。它是JavaScript的Cucumber官方端口。
请记住,与黄瓜红宝石(背景,表格,标签等)相比,它仍然缺少几个功能。
你在这里暴露的场景应该可以很好地对抗cucumber.js。
答案 3 :(得分:-1)
如果您使用的是Windows 10,则可以安装CukeTest。只需在Windows应用商店中搜索CukeTest,它就会提供可视方式来编辑小黄瓜文件并自动生成JavaScript函数。