Run Load Tests
After you are happy with your load test script (preview it in Firefox), now we get to the business: load test your application with multiple concurrent virtual users.
Example
We still use the example in previous chapter: simple google search. Here is the RWebSpec load test script:
require 'rubygems'
require 'rwebspec'
include RWebSpec::LoadTestHelper
run_with_virtual_users(5) { # You can change virtual user count here
browser = open_browser("http://www.google.com")
browser.enter_text("q", "itest2")
browser.click_button("Google Search")
sleep 0.5 # wait a bit time, as might get intermediate page
assert browser.text.include?("TestWise is a web test automation tool")
}
Run your load test
To run a load test (we use search_rwebspec.rb as the example), In MS Windows, start a 'Command Window'
> cd c:\jrubyshell > loadtest samples\google\search_rwebspec.rbYou will get output like this:
Ruby java platformRuby java platform Ruby java platform Ruby java platform Ruby java platform VU[1] 8.784s VU[3] 8.784s VU[5] 8.783s VU[2] 8.799s VU[4] 8.815s
The output (in bold) shows that it takes average 8.8 seconds for each 5 concurrent user to perform a google search.
We will visit more complex examples and reuse existing functional test script in later chapters.