我的工作轨道上的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