Rubymine 和单元测试的问题
免责声明:我对 ruby 很陌生,仍在尝试入门,所以这可能是一个非常愚蠢的问题。
我试图让一个非常简单的项目和一个单元测试工作,并且宇宙正在抛出一个 LifeException (我只是无法弄清楚)
在 Mac OS X 10.7.3 上使用 Rubymine 4.0.1。 启动 RubyMine 并创建一个新项目(不是 Rails)“TestExample” 创建了一个新的 Ruby 类,文件是 my_class.rb。
class MyClass
def say_hi
puts "Hi!"
end
end
my = MyClass.new
my.say_hi
创建一个新的 TestUnit 测试模板,文件是“my_test.rb”
require "test/unit"
class MyTest < Test::Unit::TestCase
def test_create
#my = MyClass.new
end
end
此时我有两个问题: 1. 我如何在测试中“要求”我的班级?如果我将上述测试用例更改为:
require "test/unit"
require "my_class"
class MyTest < Test::Unit::TestCase
def test_create
#my = MyClass.new
end
end
并尝试运行“所有测试:TestExample”配置,我会收到“异常消息:无法加载这样的文件 - my_class”。 Tests 文件夹和工作目录指向文件的位置。 (每个文件都位于同一文件夹中)
- 另一个是“无法将测试报告器附加到测试框架”。
我用谷歌搜索并试图弄清楚这一点但无济于事。我意识到这是两个问题合而为一,如果我能让测试正常工作,我会很高兴。
感谢您的任何意见,不要嘲笑我的超级红宝石菜鸟。
[更新] - 仅当使用 RVM:ruby-1-9.3-p125 SDK 时才会发生这种情况。如果我使用 ruby-1.8.7-p249(/usr/bin/ruby),它确实有效。这一定是一些配置问题。
DISCLAIMER: I am very new to ruby, still trying to get my feet wet, so this could be hugely stupid issue.
I'm trying to get a very simple project and one unit test working, and the Universe is throwing a LifeException (I just can't figure this out)
Using Rubymine 4.0.1 on Mac OS X, 10.7.3.
Launched RubyMine and created a new project (not Rails) "TestExample"
Created a new Ruby Class, file is my_class.rb.
class MyClass
def say_hi
puts "Hi!"
end
end
my = MyClass.new
my.say_hi
Create a new TestUnit Test Template, file is "my_test.rb"
require "test/unit"
class MyTest < Test::Unit::TestCase
def test_create
#my = MyClass.new
end
end
At this point I have two issues:
1. How do I 'require' my class in my tests? If I change the above test case to:
require "test/unit"
require "my_class"
class MyTest < Test::Unit::TestCase
def test_create
#my = MyClass.new
end
end
and attempt to run my "All tests in: TestExample" configuration, I get a "Exception message: cannot load such a file -- my_class". The Tests folder and working directory are pointed to the location of the files. (every file is in the same folder)
- The other is a "Unable to attach test reporter to test framework".
I've googled and attempted to figure this out to no avail. I realize this is two questions in one, and if I could just get tests working, I'd be happy.
Thanks for any input and don't laugh to hard at my uber-ruby-noobness.
[Update] - This only happens when using the RVM: ruby-1-9.3-p125 SDK. If I use the ruby-1.8.7-p249(/usr/bin/ruby), it does work. This has to be some configuration issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第一个问题,尝试:
我无法回答第二个问题。
For the first question, try:
I can't answer the second.