Rails 单元测试问题与 rake

发布于 2024-09-18 11:35:28 字数 631 浏览 0 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌辣 2024-09-25 11:35:28

不知何故,对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文