0

我已经开始使用 Cucumber 并在代码实现之前写了一个简单的测试,并且 cucumber 说需要 minitest。我如何在黄瓜中要求 minitest 以及应该如何或在哪个文件中要求 minitest?提前致谢。这是我的错误日志:

Warning: you should require 'minitest/autorun' instead.
From C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/test/unit/assertions.rb:1:in `<top (required)>'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:17:in `rescue in rescue in <top (required)>'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:12:in `rescue in <top (required)>'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:9:in `<top (required)>'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/options.rb:3:in `<top (required)>'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/configuration.rb:2:in `<top (required)>'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:12:in `<top (required)>'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
  C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/bin/cucumber:11:in `<top (required)>'
  C:/Ruby200/bin/cucumber:23:in `load'
  C:/Ruby200/bin/cucumber:23:in `<top (required)>'
  -e:1:in `load'
  -e:1:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From C:/Ruby200/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:670:in `<class:Runner>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:255:in `<module:Unit>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:9:in `<module:Test>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:8:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb:2:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/runtime.rb:23:in `initialize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:44:in `new'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:44:in `execute!'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/bin/cucumber:13:in `<top (required)>'
C:/Ruby200/bin/cucumber:23:in `load'
C:/Ruby200/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
4

1 回答 1

2

您遇到的特定错误是 cucumber 中的错误,已在 cucumber 1.3.3 的最新版本中修复。

您可能还需要这样的东西:

require 'minitest'
module MiniTestAssertions
  def self.extended(base)
    base.extend(MiniTest::Assertions)
    base.assertions = 0
  end

  attr_accessor :assertions
end
World(MiniTestAssertions)

在您的features/support/目录中。

请参阅黄瓜问题:#489456

于 2013-07-08T14:18:16.450 回答