LoadWise

Simple and affordable web load testing

Version 0.6.0

Windows XP +

Script Reuse - Easy to Maintain Load Test

Maintainability, generally is not under radar of load testers. Most of commercial load testing tools heavily rely on its recording functions. As we know, with number of load test scripts increases, maintenance effort grows exponentially. Recording is not good answer.

RWebSpec load test scripts are not only readable and flexible, but also easy to maintain through script reuse.

Example

We use the test script in previous chapter.

load File.join(File.dirname(__FILE__), "test_helper.rb")

#...

  it "(Refactored version): Book flight using Page object design" do

    stats = run_with_virtual_users() {
      browser = open_browser
      log_time("Open home page") { browser.goto_page("/") }
      home_page = HomePage.new(browser)
      home_page.enter_user_name("agileway")
      home_page.enter_password("test")
      log_time("Sign in") { home_page.click_sign_in }
      browser.text.should include("Welcome agileway")

      flight_finder_page = FlightFinderPage.new(browser)
      flight_finder_page.select_trip_type_return
      flight_finder_page.select_departing_from("New York")
      flight_finder_page.select_arriving_in("Sydney")
      flight_finder_page.select_departing_day("02")
      flight_finder_page.select_departing_month("September 2012")
      flight_finder_page.select_returning_day("05")
      flight_finder_page.select_returning_month("October 2012")
      log_time("Select Flight") { flight_finder_page.click_continue }

      passenger_page = PassengerPage.new(browser)
      passenger_page.enter_first_name "Wendy"
      passenger_page.enter_last_name "The Boss"
      log_time("Submit Passenger") { passenger_page.click_next }

      browser.text.should include("Pay by Credit Card")
      
      # calling function defined in helper
      @browser = browser
      log_time("Sign off") { sign_off }
    }

  end

As we see, you can use functions defined in test_helper.rb and all Page Classes defined. For instance, if programmer made a change to home page (change field 'username' to 'login'). If test scripts created as above, no matter how many test scripts you have, you only need to update one place: home_page.rb.