2011-01-11 41 views
0

如何使用设计运行性能测试。使用设计文档我有这个在我的test_helper.rb中使用设计认证进行性能测试

class ActionController::TestCase 
    include Devise::TestHelpers 
end 

Functional testing with Rails and Devise. What to put in my fixtures?,我有这个在我的性能测试:

require 'test_helper' 
require 'rails/performance_test_help' 

class EditorTest < ActionDispatch::PerformanceTest 

    def test_create 

    @user = users(:one) 
    sign_in @user 

    get 'documents/new/1' 
    end 

end 

我收到以下错误

NoMethodError: undefined method `sign_in' for #<EditorTest:0xb6bc0654 ...> 
    /test/performance/editor_test.rb:9:in `test_create' 

如何在性能测试中是否正确包含Devise TestHelpers?

谢谢!

这可以作为功能测试。

[编辑]

包括ActionDispatch :: PerformanceTest的色器件助手和运行红宝石-d试验后,这里是调试输出的底部:

/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb: 

53: warning: instance variable @request not initialized 
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/ 
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined 
method `env' for nil:NilClass 
EEditorTest#test_create (0 ms warmup) 
/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb: 

53: warning: instance variable @request not initialized 
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/ 
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined 
method `env' for nil:NilClass 
E  process_time: 0 ms 
Exception `Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - 

File exists - tmp/performance Exception Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/performance Exception Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/performance

的短版上述错误:

NoMethodError: undefined method `env' for nil:NilClass 

回答

2

(误读问题原始回答错误的问题如下。)

尝试增加

class ActionDispatch::PerformanceTest 
    include Devise::TestHelpers 
end 

到你的助手文件的底部。


(原件回复)

确保

class ActionController::TestCase 
    include Devise::TestHelpers 
end 

是你的助手文件的底部一路。它不应该在ActiveSupport::TestCase类中。

+0

它的底部。功能测试已经开始。这只是性能测试。 – joshs 2011-01-11 04:14:58

+0

查看最新回复。 – 2011-01-11 04:31:30