我的工作軌道上的3.1.1和使用socery 0.7.11進行驗證,我需要實現性能測試中,我可以測試下面的事情如何啓動性能測試
- 模擬100個用戶簽約同時開啓和關閉
- 模擬100位用戶同時添加新興趣。
我必須經過以下環節:
http://rubylearning.com/blog/2011/08/14/performance-testing-rails-applications-how-to/
http://guides.rubyonrails.org/performance_testing.html
而且能夠做以下的事情
- 創建的測試文件夾test_helper.rb中
- 創建測試/性能/ login_test.rb
- 創建夾具/ users.yml裏
test_helper.rb中
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
/performance/login_test.rb
require 'test_helper'
require 'rails/performance_test_help'
class LoginTest < ActionDispatch::PerformanceTest
fixtures :users
# Refer to the documentation for all available options
self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory],
:output => 'tmp/performance', :formats => [:flat] }
def test_login
post_via_redirect "http://bc.lvh.me/", :username => users(:youruser).username, :password => users(:youruser).password
#using lvh.me coz login page is on my subdomain
end
end
夾具/ users.yml裏
one:
username: eagleschasar12
password: chaitanyA1#
two:
username: eaglesmarktell12
password: chaitanyA1#
當我運行耙測試:個人資料,我得到了以下結果
E
===============================================================================
Error: test_login(LoginTest)
ActiveRecord::StatementInvalid: SQLite3::SQLException: table users has no column named password: INSERT INTO "users" ("username", "password", "created_at", "updated_at", "id") VALUES ('eagleschasar12', 'chaitanyA1#', '2012-06-15 06:43:01', '2012-06-15 06:43:01', 980190962)
所以我的問題是
- 爲什麼測試命令發射插入查詢?
- 我是否需要在夾具文件中寫入100條用戶記錄以測試功能?
- 如何檢查會話登錄/註銷?
- 另外,當我從數據庫中選擇興趣類型時,我的用戶應該登錄系統,那麼如何在性能測試中測試這種情況?
- 此測試是否在webrick上運行,這是我的本地服務器。
是的,你是正確的下一次,我會照顧好這個(約合問一個問題),非常感謝給我一個方向 – chaitanya