Ruby on rails &引用;耙;我所有的黄瓜测试都运行良好,但是;黄瓜“;不';我没有台阶
我继承了一个Rails(3)应用程序,并正在努力掌握现有的Cumber测试。我在应用程序的“功能”文件夹中设置了以下内容(我遗漏了任何不相关的文件,例如额外的功能和步骤) 如果我运行“rake”,那么它将正确地使用步骤定义中列出的步骤运行features/people/new-person.feature中的所有功能 但是,我不想每次都运行rake,因为它需要太长时间,我只想在Cucumber中运行一个特定的测试,例如,Ruby on rails &引用;耙;我所有的黄瓜测试都运行良好,但是;黄瓜“;不';我没有台阶,ruby-on-rails,ruby-on-rails-3,cucumber,Ruby On Rails,Ruby On Rails 3,Cucumber,我继承了一个Rails(3)应用程序,并正在努力掌握现有的Cumber测试。我在应用程序的“功能”文件夹中设置了以下内容(我遗漏了任何不相关的文件,例如额外的功能和步骤) 如果我运行“rake”,那么它将正确地使用步骤定义中列出的步骤运行features/people/new-person.feature中的所有功能 但是,我不想每次都运行rake,因为它需要太长时间,我只想在Cucumber中运行一个特定的测试,例如,Cucumber features/people/new-person.fe
Cucumber features/people/new-person.feature-l 8
当我这样做时,它运行该功能,但没有加载步骤。我把这个拿回来:
Using the default profile...
Feature: Add a new person
In order to allocate tasks to people
As a community manager
I want to add a new person
Scenario: Secondary navigation should contain "Add new person" # features/people/new-person.feature:8
Given I am on the new person page # features/people/new-person.feature:9
Undefined step: "I am on the new person page" (Cucumber::Undefined)
features/people/new-person.feature:9:in `Given I am on the new person page'
Then I should not see "Add new person" # features/people/new-person.feature:10
Undefined step: "I should not see "Add new person"" (Cucumber::Undefined)
features/people/new-person.feature:10:in `Then I should not see "Add new person"'
1 scenario (1 undefined)
2 steps (2 undefined)
0m0.005s
You can implement step definitions for undefined steps with these snippets:
Given /^I am on the new person page$/ do
pending # express the regexp above with the code you wish you had
end
Then /^I should not see "([^"]*)"$/ 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.
Cucumber为什么不把台阶装进去?我猜我需要一些步骤,但我不知道在哪里
谢谢,MaxMax Williams找到了他的问题的答案: 编辑-在此处找到答案: 在config/cucumber.yml中有一行如下所示:
std_opts=“--format#{ENV['CUCUMBER_format']| |'pretty'}--strict--tags~@wip”
换成
std_opts=“--format#{ENV['CUCUMBER_format']| | pretty'}--strict--tags~@wip--require features/”
这就像在cucumber测试运行结束时添加
--require features/
,并使其正确加载所有内容。无论出于何种原因,我还没有一个cucumber.yml文件要更改。因此,只需创建一个空白的/config/cucumber.yml文件并将该行放入其中:
std_opts=“--format#{ENV['cumber_format']||'pretty'}--strict--tags~@wip--require features/”
不起作用。(这并不奇怪,我想应该不止这一行。)
我在这里找到了一个完整、有效的cucumber.yml示例文件的好例子:为了便于讨论,请将功能文件向上移动一个目录。在我的各种.feature文件中我没有任何要求,在features/support/files中我也没有看到任何指向这一点的配置错误。您确定您的people_steps.rb代码功能正常吗?你牺牲了一只鸡吗?@jaydel-当我用简单的
rake
运行它时,一切都很好。我想继续细分我的功能,只是为了将它们组织到合理的组中。@jaydel-但是,将功能文件移动到主功能文件夹中确实解决了问题。。。一定有什么地方需要我加上额外的“./”我想。啊,太好了。好东西。感谢您将其带回我们:)请将您的解决方案作为答案发布,并在两天内接受。这样,它将正确显示为问题列表和搜索结果中的答案。@Max,您应该接受此答案。此外,如果您不想添加默认选项,您可以在运行Cumber时向其添加-r功能/
。
Using the default profile...
Feature: Add a new person
In order to allocate tasks to people
As a community manager
I want to add a new person
Scenario: Secondary navigation should contain "Add new person" # features/people/new-person.feature:8
Given I am on the new person page # features/people/new-person.feature:9
Undefined step: "I am on the new person page" (Cucumber::Undefined)
features/people/new-person.feature:9:in `Given I am on the new person page'
Then I should not see "Add new person" # features/people/new-person.feature:10
Undefined step: "I should not see "Add new person"" (Cucumber::Undefined)
features/people/new-person.feature:10:in `Then I should not see "Add new person"'
1 scenario (1 undefined)
2 steps (2 undefined)
0m0.005s
You can implement step definitions for undefined steps with these snippets:
Given /^I am on the new person page$/ do
pending # express the regexp above with the code you wish you had
end
Then /^I should not see "([^"]*)"$/ 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.