Rails 单元测试问题与 rake
我正在为 Rails 2.3.4 应用程序编写测试,当我尝试运行测试时遇到以下错误
1) 失败: default_test(ReportTest) [rake (0.8.7) lib/rake/rake_test_loader.rb:5]: 没有指定测试。
这是唯一的测试文件的样子:
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < ActiveSupport::TestCase
include Authlogic::TestCase
setup :activate_authlogic
fixtures :users
def setup
@user = users(:one)
end
def test_user_is_valid
assert @user.valid?
end
end
我可以预见到的一个问题是我安装了多个版本的 Rails 和 rake
rails (3.0.0, 2.3.8, 2.3.5, 2.3.4, 1.2.6)
rake (0.8.7, 0.8.3)
有人知道发生了什么吗?
I am working on writing tests for a rails 2.3.4 application and I am running into the following error when I try to run the tests
1) Failure:
default_test(ReportTest) [rake (0.8.7) lib/rake/rake_test_loader.rb:5]:
No tests were specified.
This is what the only test file looks like:
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < ActiveSupport::TestCase
include Authlogic::TestCase
setup :activate_authlogic
fixtures :users
def setup
@user = users(:one)
end
def test_user_is_valid
assert @user.valid?
end
end
One issue I could forsee being a problem is that I have multiple versions of rails installed and rake as well
rails (3.0.0, 2.3.8, 2.3.5, 2.3.4, 1.2.6)
rake (0.8.7, 0.8.3)
Anyone know what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知何故,对
rake test
进行的测试搜索发现了一个名为_test.rb
的文件,其中没有测试。它将查看 test/units /functions 和 /integration 目录下的所有文件以尝试找到测试。我也曾经有过奇怪的行为,另一个 Rails 应用程序的子目录中的 Rails 应用程序发现的测试比它应该做的要多,因为它从“父”应用程序中获取测试。可能也值得检查一下。
Somehow the search for tests that
rake test
does has turned up a file named_test.rb
which doesn't have a test in it. It will look through all the files under the test/units /functionals and /integration directories to try and locate tests.I also once had the strange behaviour that a rails application in a sub directory of another rails application was finding more tests than it should have done as it was picking up tests from the 'parent' application. Might be worth checking that too.