使用http://guides.rubyonrails.org/performance_testing.html#examples (1.2.1) 中的示例:
require 'test_helper'
require 'rails/performance_test_help'
class PostPerformanceTest < ActionDispatch::PerformanceTest
def setup
# Application requires logged-in user
login_as(:lifo)
end
def test_homepage
get '/dashboard'
end
def test_creating_new_post
post '/posts', :post => { :body => 'lifo is fooling you' }
end
end
根据文档,它说setup
每个测试调用一次,但是当我像示例一样运行测试时,会话保持不变,下一次setup
调用使用旧会话。我使用reset!
, 来清除设置中的会话。
那是对的吗?我是否也需要在集成测试中做同样的事情?为什么在世界上保持会话?也许我错过了一些东西,比如是否有一种技术可以查看是否存在记录/会话?