简体   繁体   English

耙的Rails单元测试问题

[英]Rails Unit Test Issue with rake

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 我正在为Rails 2.3.4应用程序编写测试,并且在尝试运行测试时遇到以下错误

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以及rake

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? 有人知道发生了什么吗?

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. 不知何故,搜索rake test所做的rake test会发现一个名为_test.rb的文件,其中没有测试。 It will look through all the files under the test/units /functionals and /integration directories to try and locate tests. 它将浏览test / units / functionals和/ integration目录下的所有文件,以尝试找到测试。

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. 我也曾经有过一个奇怪的行为,那就是另一个Rails应用程序的子目录中的Rails应用程序正在寻找比它从“父”应用程序中获取测试更多的测试。 Might be worth checking that too. 也可能值得检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM