[英]Cucumber: Automatic step file creation?
當我運行黃瓜時,它會顯示我應該定義的可能步驟,這是RSpec書中的一個例子:
1 scenario (1 undefined)
4 steps (4 undefined)
0m0.001s
You can implement step definitions for undefined steps with these snippets:
Given /^I am not yet playing$/ do
pending
end
When /^I start a new game$/ do
pending
end
Then /^the game should say “Welcome to CodeBreaker”$/ do
pending
end
Then /^the game should say “Enter guess:”$/ do
pending
end
有沒有辦法,它會自動創建步驟定義文件,所以我不必手動重寫或復制粘貼,但我可以只是自定義它們更通用?
黃瓜不提供此功能。 可能是因為你必須告訴它在哪里放置步驟定義文件,以及命名它。
就像Kevin說的那樣,Cucumber必須知道要放入文件的名稱,除了使用與功能文件相同的文件名之外,沒有好的默認設置。 這是我認為反模式的東西: http : //wiki.github.com/aslakhellesoy/cucumber/feature-coupled-steps-antipattern
Intellij Idea或RubyIDE完全符合您的要求:
有關一步一步的圖片,請參見http://i48.tinypic.com/10r63o4.gif
請享用
這種功能有可能是有用的,但正如凱文所說,它目前還不存在。 但它也可能很快變得非常混亂。
也許你已經這樣做了,但沒有什么可以阻止你直接將輸出剪切並粘貼到文本編輯器中,或者如果你願意的話,甚至可以直接將輸出匯總到你的文本編輯器。 那么至少你在那里的大部分時間都是如此,無論是創建文件還是命名。
試試這個https://github.com/unxusr/kiwi它自動生成你的功能文件並為你制作步驟定義文件,你只需用代碼填寫步驟。 在以后的版本中,將編寫步驟的代碼並自動運行所有這些測試
您可以使用解決方法生成步驟文件所有您需要做的就是通過將特定功能標識為以下命令來運行功能上沒有已定義步驟的Cucumber:
1)使用路徑
bundle exec cucumber {PATH}
note path would start with features/....
for example
features/users/login.feature
1)使用標簽
bundle exec cucumber --tags=@{TAG}
note tag should be above your scenario in the steps file
for example
@TAG
Scenario:
並且您將在控制台中具有待處理狀態的建議步驟
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.