Test::Unit 2.x 测试从 rake 运行但从自动测试失败
我在使用 Test::Unit 2.0.6 通过自动测试运行 Rails 单元测试时遇到问题。通过 rake test:units 运行测试效果很好,但是当我从 autotest 运行测试时,我得到:
/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
Versions:
- Mac OS X 10.6.3
- ruby 1.8.7 (2009-06-08 patchlevel 173 ) [universal-darwin10.0]
- Rails 2.3.5 (基于 Suspenders)
- autotest (4.3.2)
- autotest-fsevent (0.1.3)
- autotest-growl (0.1.7)
- autotest-rails (4.1.0)
- ZenTest (4.3 ) .3)
- test-unit (2.0.6)
test-unit 2.0.9 也会出现此问题。我已经尝试了 尝试时出现未初始化的常量错误中的建议运行测试并在http://floehopper.lighthouseapp.com/ items/22289-mocha/tickets/50,但仍然没有运气。
如果我删除需要 Test::Unit 2.x 的断言并删除测试单元 gem,自动测试就可以正常工作。不幸的是,我需要使用 2.x 断言。
有什么想法吗?预先感谢您的任何帮助。
I'm having problems running my Rails unit tests via autotest using Test::Unit 2.0.6. Running tests via rake test:units
works perfectly, but when I run the tests from autotest, I get this:
/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
Versions:
- Mac OS X 10.6.3
- ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
- Rails 2.3.5 (based on Suspenders)
- autotest (4.3.2)
- autotest-fsevent (0.1.3)
- autotest-growl (0.1.7)
- autotest-rails (4.1.0)
- ZenTest (4.3.3)
- test-unit (2.0.6)
The problem also occurs with test-unit 2.0.9. I've tried the suggestions in Getting uninitialized constant error when trying to run tests and at http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/50, but still no luck.
Autotest works just fine if I remove the assertions that require Test::Unit 2.x and remove the test-unit gem. Unfortunately, I need to use the 2.x assertions.
Any ideas? Thanks in advance for any assistance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题:从 rake 运行时测试工作正常。但是当我尝试自动测试时,我遇到了同样的错误:
我正在运行 shoulda 2.10.3、mocha 0.9.8 和 test-unit 2.1.0。我已经在宝石加载顺序上胡闹了,以使摩卡和应该感到高兴,正如我所说,耙子测试一切都很好。我尝试过多个版本的 ZenTest(4.3.3、4.1.1)。我尝试过独立版本的自动测试(4.3.2)。结果相同。我尝试使用测试单元 1.2.3 而不是 2.1.0,但这破坏了我的测试的其他部分。
I'm having the same problem: tests work fine when run from rake. But when I try autotest I get the same errror:
I'm running shoulda 2.10.3, mocha 0.9.8, and test-unit 2.1.0. I had already monkeyed around with gem loading order to make mocha and shoulda happy and as I said things are fine with rake test. I've tried multiple versions of ZenTest (4.3.3, 4.1.1). I've tried a standalone version of autotest (4.3.2). Same results. I've tried using test-unit 1.2.3 instead of 2.1.0 but that breaks other parts of my tests.
我遇到了类似的问题,虽然我知道这真的很晚了,但问题是我没有安装 autotest-rails。
I ran into a similar issue, and while I know this is really late, the problem was that I didn't have autotest-rails installed.