我在使用Test :: Unit 2.0.6通过自动测试运行我的Rails单元测试时遇到问题。通过rake test:units
运行测试非常有效,但是当我从自动测试运行测试时,我得到了这个:
/Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError) from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.6/lib/test/unit/testresult.rb:28 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.6/lib/test/unit/ui/testrunnermediator.rb:9 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.6/lib/test/unit/ui/console/testrunner.rb:11 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:25 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:214:in `[]' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:214:in `run' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit.rb:278 from -e:1
版本:
测试单元2.0.9也会出现问题。我在Getting uninitialized constant error when trying to run tests和http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/50尝试了这些建议,但仍然没有运气。
如果我删除需要Test :: Unit 2.x的断言并删除测试单元gem,则自动测试工作正常。不幸的是,我需要使用2.x断言。
有什么想法吗?提前感谢您的任何帮助。
答案 0 :(得分:1)
我遇到了同样的问题:从rake运行时测试工作正常。但是当我尝试自动测试时,我得到同样的错误:
`const_missing': uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError)
我正在运行的应该是2.10.3,mocha 0.9.8和测试单元2.1.0。我已经开始使用宝石加载命令来制作摩卡,并且应该开心,正如我所说的那样,用rake测试就可以了。我尝试过多个版本的ZenTest(4.3.3,4.1.1)。我尝试过一个独立版本的自动测试(4.3.2)。结果相同。我尝试过使用测试单元1.2.3而不是2.1.0,但这会破坏我测试的其他部分。
答案 1 :(得分:0)
我遇到了类似的问题,虽然我知道这已经很晚了,但问题是我没有安装autotest-rails。