【问题标题】:Cuke4nuke: Is it missing the support for different languages?Cuke4nuke:是否缺少对不同语言的支持?
【发布时间】:2010-09-28 11:15:36
【问题描述】:

我使用的是 0.3.1 版的 Cuke4Nuke,但在使用英语以外的其他语言定义我的功能文件时遇到问题。谷歌搜索没有带来任何解决方案,所以我的问题很简单:Cuke4Nuke 是否支持用英语以外的其他语言定义功能?

我尝试使用 GitHub 的 Cucumber 存储库中的示例。这是一个不起作用的功能示例:

# language: no
Egenskap: Summering
  For å unngå at firmaet går konkurs
  Må regnskapsførerere bruke en regnemaskin for å legge sammen tall

Scenario: to tall
  Gitt at jeg har tastet inn 5
  Og at jeg har tastet inn 7
  Når jeg summerer
  Så skal resultatet være 12

编译并通过 Cuke4Nuke 运行时,错误消息如下:

Cuke4Nuke C:_work\myProject\Tests\Integration.Tests\bin\Debug\Integration.Tests.dll C:_work\myProject\Tests\Integration.Tests\features -q C:/_work/myProject/Tests/Integration.Tests/features/summering.feature: 第 2 行的词法错误:'Egenskap: 避暑”。看 http://wiki.github.com/aslakhellesoy/gherkin/lexingerror 了解更多信息。 (Gherkin::Lexer::LexingError) C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/gherkin-2.2.4-x86-mingw32/lib/gherkin/lexer/i18n_lexer.rb:22:in scan' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/gherkin-2.2.4-x86-mingw32/lib/gherkin/lexer/i18n_lexer.rb:22:in scan' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/gherkin-2.2.4-x86-mingw32/lib/gherkin/parser/parser.rb:31:in parse' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/feature_file.rb:35:in parse' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime/features_loader.rb:28:in load' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime/features_loader.rb:26:in each' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime/features_loader.rb:26:in load' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime/features_loader.rb:14:in features' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime.rb:179:in features' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/runtime.rb:32:in run! C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/cli/main.rb:54:in execute!' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/../lib/cucumber/cli/main.rb:29:in 执行' C:/_work/tools/Ruby186/lib/ruby/gems/1.8/gems/cucumber-0.9.0/bin/cucumber:8 C:/_work/tools/Ruby186/bin/cucumber:19:in load'load '

似乎 cuke4nuke(或 Cucumber?)完全跳过了 # 语言声明。例如,以下功能在不应该的情况下起作用。

# language: fi
Feature: Addition
In order to avoid silly mistakes
As a math idiot 
I want to be told the sum of two numbers

Scenario Outline: Add two numbers
Given I have entered <input_1> into the calculator
And I have entered <input_2> into the calculator
When I press <button>
hen the result should be <output> on the screen

Examples:
| input_1 | input_2 | button | output |
| 20      | 30      | add    | 50     |
| 2       | 5       | add    | 7      |
| 0       | 40      | add    | 40     |

任何想法如何让 Cucumber 和 Cuke4Nuke 注意到语言声明?我的 Ruby 是 1.86 版,Cucumber 是 0.9 版。

【问题讨论】:

  • 您了解 SpecFlow (www.specflow.org)。它使用与 Cucumber 相同的 Gherkin Parser,但在 .NET 上本机运行。 (免责声明:我是 SpecFlow 的提交者。)
  • 感谢您的评论。我最终搬到了 SpecFlow,从那以后我一直在愉快地使用它。

标签: c# .net cucumber


【解决方案1】:

在 Cuke4Nuke 之前,这看起来像是 Cucumber/Gherkin 方面的错误。语言声明仅在 Cucumber 端处理。当步骤详细信息到达 Cuke4Nuke 时,关键字已经消失。您可能会在 cukes 组 (groups.google.com/group/cukes/) 上获得更多帮助;我认为 Cucumber 开发人员在那里更活跃。

也就是说,Cuke4Nuke 还不支持语言。您仍然必须在步骤定义中使用 Given/When/Then 属性,而不是 Gitt/Når/Så,并且步骤定义参数的字符串转换不会使用正确的文化,这可能会给您带来问题。下一个 Cuke4Nuke 版本将包括语言支持。 i18n 属性已经在最新的源中,我正在研究文化方面的东西。

【讨论】:

  • 感谢您的回答。我从 GitHub 下载、构建并安装了最新版本的 Cuke4Nuke,并尝试运行包含的语言示例,但我在该示例上遇到了同样的错误。因此,就像您提到的那样,问题似乎在 Cucumber 方面。我现在在两台不同的计算机上对此进行了测试,它们都有相同的问题,尽管它们都是 Win x64 机器。
猜你喜欢
  • 1970-01-01
  • 2013-10-26
  • 2013-09-16
  • 1970-01-01
  • 2016-10-22
  • 1970-01-01
  • 2017-08-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多