3

私は自分のレールアプリケーションにtest_helper.rb以下を含めました。の下のファイルにtestも含め require 'test_helper'ました。アプリケーションの RubyMine ですべてのテストを実行すると、次のエラーが発生します。test.rbtest->unit

RubyMine 3.2、ruby 1.9.2p290、Rails 3.1.0 のすべての最新バージョンを持っています。

/Users/im/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb
Testing started at 3:19 PM ...
Work directory: /Users/im/RubymineProjects/BackChannelApp}
Loading files.... 
=========================================
Fail to load: /Users/im/RubymineProjects/BackChannelApp/test/performance/browsing_test.rb:1
      Exception message: no such file to load -- test_helper
        /Users/im/RubymineProjects/BackChannelApp/test/performance/browsing_test.rb:1:in `require'
        /Users/im/RubymineProjects/BackChannelApp/test/performance/browsing_test.rb:1:in `<top (required)>'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `require'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `block in load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `each'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:101:in `<top (required)>'
        -e:1:in `load'
        -e:1:in `<main>'
Fail to load: /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/posts_helper_test.rb:1
      Exception message: no such file to load -- test_helper
        /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/posts_helper_test.rb:1:in `require'
        /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/posts_helper_test.rb:1:in `<top (required)>'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `require'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `block in load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `each'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:101:in `<top (required)>'
        -e:1:in `load'
        -e:1:in `<main>'
Fail to load: /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/users_helper_test.rb:1
      Exception message: no such file to load -- test_helper
        /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/users_helper_test.rb:1:in `require'
        /Users/im/RubymineProjects/BackChannelApp/test/unit/helpers/users_helper_test.rb:1:in `<top (required)>'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `require'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `block in load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `each'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:101:in `<top (required)>'
        -e:1:in `load'
        -e:1:in `<main>'
Fail to load: /Users/im/RubymineProjects/BackChannelApp/test/unit/post_test.rb:1
      Exception message: no such file to load -- test_helper
        /Users/im/RubymineProjects/BackChannelApp/test/unit/post_test.rb:4:in `require'
        /Users/im/RubymineProjects/BackChannelApp/test/unit/post_test.rb:4:in `<top (required)>'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `require'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `block in load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `each'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:101:in `<top (required)>'
        -e:1:in `load'
        -e:1:in `<main>'
Fail to load: /Users/im/RubymineProjects/BackChannelApp/test/unit/user_test.rb:1
      Exception message: no such file to load -- test_helper
        /Users/im/RubymineProjects/BackChannelApp/test/unit/user_test.rb:1:in `require'
        /Users/im/RubymineProjects/BackChannelApp/test/unit/user_test.rb:1:in `<top (required)>'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `require'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:48:in `block in load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `each'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:40:in `load_scripts_to_object_space'
        /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:101:in `<top (required)>'
        -e:1:in `load'
        -e:1:in `<main>'
Creating sqlite :memory: database
-- create_table("posts", {:force=>true})
   -> 0.0346s
-- create_table("users", {:force=>true})
   -> 0.0010s
-- initialize_schema_migrations_table()
   -> 0.0008s
-- assume_migrated_upto_version(20110926132602, ["db/migrate"])
   -> 0.0005s
1. /Users/im/RubymineProjects/BackChannelApp/test/test_helper.rb:1

1 files were loaded.
=========================================
Searching test suites...
=========================================
DEPRECATION WARNING: ActiveSupport::JSON::CircularReferenceError is deprecated! Use ActiveSupport::JSON::Encoding::CircularReferenceError instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
DEPRECATION WARNING: ActiveSupport::JSON::CircularReferenceError is deprecated! Use ActiveSupport::JSON::Encoding::CircularReferenceError instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
DEPRECATION WARNING: Fixtures is deprecated! Use ActiveRecord::Fixtures instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
DEPRECATION WARNING: Fixtures is deprecated! Use ActiveRecord::Fixtures instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
DEPRECATION WARNING: Fixture is deprecated! Use ActiveRecord::Fixture instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
DEPRECATION WARNING: Fixture is deprecated! Use ActiveRecord::Fixture instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
Test suite #1: ActionDispatch::IntegrationTest

Ignored because it is default rails empty test suite
=========================================
Test suite #1: ActiveSupport::TestCase

Ignored because it is default rails empty test suite
=========================================
Test suite #1: ActionController::TestCase

Ignored because it is default rails empty test suite
DEPRECATION WARNING: ActiveSupport::SecureRandom is deprecated! Use SecureRandom instead. (called from is_test_case_class? at /Applications/RubyMine 3.2.4.app/rb/testing/runner/tunit_in_folder_runner.rb:80)
=========================================
Test suite #1: ActiveRecord::TestCase

Ignored because it is default rails empty test suite
=========================================
0 test suites, 0 tests, 0 assertions, 0 failures, 0 errors


Process finished with exit code 0

私は何が欠けていますか?ありがとう!

4

2 に答える 2

1

test_helper.rb は test ディレクトリ内にあります。ルート ディレクトリからテストを実行しているため、ファイルへのパスが間違っています。test ディレクトリからテストを実行してみてください。

ルート ディレクトリからテストを実行する場合は、これを に変更する必要がありますrequire File.join(File.dirname(__FILE__), '..', 'test_helper.rb')。ここで、FILE はこの行 (テスト ケース) を含むファイルへのパスであり、残りは test_helper.rb の相対パスです。そのファイルに。このように、どこからテストを実行するかは関係ありません。

于 2011-09-28T08:35:38.387 に答える