我创建了search.feature
和search.rb
文件来建立自动测试。之后,我在终端上运行命令并得到一个错误。如何解决?
我已经在Windows Ruby 2.6.1
和Cucumber 3.1.2
上的Linux子系统上尝试过
这是 search.feature 文件的代码:
The google homepage allows user to perform a search.
Scenario Outline: Users can perform a search on Google
Given I open the Google search page
When I search for "<search>"
Then I should see the results page
Examples :
| search |
| baju |
| bola |
| indonesia |
这是 search.rb 文件的代码:
Given /^I open the Google search page$/ do
visit "/"
end
Given /^I search for "(.*?)"$/ do |search_term|
@page_search = SearchPage.new
@page_search.search(search_term)
end
Then /^I should see the results page$/ do
expect(@page_search).to have_search_field
end
在那之后,当我在终端上运行命令时,出现了这样的错误:
➜ cucumber-native cucumber
features/scenario/search/search.feature: Parser errors:
(9:2): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'Examples :' (Cucumber::Core::Gherkin::ParseError)
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:34:in `rescue in document'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:28:in `document'/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:30:in `block in parse'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `each'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `parse'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:21:in `compile'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:75:in `run!'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
/home/oimtrust/.rvm/gems/ruby-2.6.1/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
/home/oimtrust/.rvm/gems/ruby-2.6.1/bin/cucumber:23:in `load'
/home/oimtrust/.rvm/gems/ruby-2.6.1/bin/cucumber:23:in `<main>'
/home/oimtrust/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/home/oimtrust/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>'
答案 0 :(得分:1)
Examples
部分必须嵌套在Scenario
Scenario Outline: Users can perform a search on Google
Given I open the Google search page
When I search for "<search>"
Then I should see the results page
Examples:
| search |
| baju |
| bola |
| indonesia |