【发布时间】:2012-12-09 07:07:22
【问题描述】:
Errors running test:units! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/Users/jake/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.2/lib" "/Users/jake/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.2/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]>
这是否意味着我的单元测试文件有问题,或者我的模型有问题?或者两者都可以?
下面的完整跟踪。
[app:]$ rake test --trace
** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Execute test:run
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:test:purge
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load
** Execute test:prepare
** Execute test:units
Run options:
# Running tests:
..F
Finished tests in 0.411867s, 7.2839 tests/s, 7.2839 assertions/s.
1) Failure:
test_should_save_user_with_valid_email_and_password(UserTest) [/Users/jake/Sites/app/test/unit/user_test.rb:9]:
Didn't save a valid record
3 tests, 3 assertions, 1 failures, 0 errors, 0 skips
** Invoke test:functionals (first_time)
** Invoke test:prepare
** Execute test:functionals
Run options:
# Running tests:
Finished tests in 0.004578s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
** Invoke test:integration (first_time)
** Invoke test:prepare
** Execute test:integration
Errors running test:units! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/Users/jake/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.2/lib" "/Users/jake/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.2/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" ]>
编辑
此错误仅在 rake 返回错误时显示。如果没有错误,运行测试的这个错误也不会出现......好奇和好奇......
【问题讨论】:
-
我不太明白您所说的“当 rake 返回错误时”是什么意思。你的意思是,如果你运行
rake test:units或rake test:functionals没有 Rake 错误,但有rake test:integration(或rake test包括它)?如果是这样,那就是领先。 -
抱歉,当 rake test:units 返回错误时,会出现该错误。当 rake test:units 不返回错误时,该错误不会出现。这听起来很明显,但这是我要问的最后一行,
Errors running test:units! -
我想我遇到的问题是理解为什么
rake test:units有时会为您返回错误,有时不会。这是真正的问题吗? -
因此,如果我的代码中有错误,它会显示我的代码中的错误,以及上面有问题的错误。如果我修复了错误,报告中显然不会出现错误,但上述错误也不会出现。
-
我相信“错误运行测试:单位!”只是表明(一些)你的测试没有通过。
标签: ruby-on-rails unit-testing testing rake