Alister Scott @ Australian Test Automation Workshop TAW 2009 - Presentation Transcript
using Watir to create a super easy, highly maintainable, business-focused framework (for free ! ) Alister Scott
About Me Testing Team Leader QSuper Limited Wiki Master Watir Open Source Project
About Watir Web Application Testing in Ruby An open source (BSD) ruby library for automating browsers (that rocks!) Built for ease of use An active & friendly community
About Watir No need for server side stuff No need for java stuff, pure ruby Need a test execution/assertion library Test::Unit is the ruby default RSpec is another Cucumber is hip No red button (use irb instead!)
A tale of two frameworks the ' all spreadsheet ' way easy for business to understand; but difficult for us to maintain! generally discourage re-use and efficient coding practices
A tale of two frameworks the ' all code ' way easy for us to maintain; but difficult for business to understand; generally difficult to express business scenarios ( but cucumber makes it easier )
A better way? What about an in-between?
Test case design is done in spreadsheets (easy for testers/business ppl) Test execution design is done in code (easy for automated testers)
Creating an in-between framework using Watir , and roo
Not another google example You specifically agree not to access (or attempt to access) any of the Services through any automated means (including use of scripts or web crawlers)
A business focused data sheet test case design Function Test Comments Expected Outcome Expected Error Customer Empty Cart Success Function Test Comments Expected Outcome Expected Error Book Title Customer Add Book Negative Test Error Could not locate title in store Ruby on Rails Customer Add Book Success Pragmatic Unit Testing (C#) Function Test Comments Expected Outcome Expected Error Expect Cart Total Customer Check Cart Total Success 59.9
Business scenarios calls Customer.add_book( “ Ruby on Rails ” ) Function Test Comments Expected Outcome Expected Error Customer Empty Cart Success Function Test Comments Expected Outcome Expected Error Book Title Customer Add Book Negative Test Error Could not locate title in store Ruby on Rails Customer Add Book Success Pragmatic Unit Testing (C#) Function Test Comments Expected Outcome Expected Error Expect Cart Total Customer Check Cart Total Success 59.9
Customer.add_book(book_title) test execution design def Customer.add_book(book_title) browser = Common.find_or_start_store(TITLE, URL) # Check if title is already in cart - so we can check it was added correctly browser.link(:text,'Show my cart').click prev_cart_count = 0 prev_cart_total = 0.00 if not browser.div(:text,'Your cart is currently empty').exist? then # We have a non-empty cart for row in browser.table(:index,1) if row[2].text == book_title then prev_cart_count = row[1].text.to_i break end end prev_cart_total = browser.cell(:id, 'totalcell').text[1..-1].to_f #remove $ sign browser.link(:text, 'Continue shopping').click end
Why separate test case & test execution design? we can change either without updating both (add test cases without writing code) we can change test execution without changing our existing test cases (new interface, move to SOA)
This could just as easily test a SOA calls CustomerAddBook SOAP web service Function Test Comments Expected Outcome Expected Error Customer Empty Cart Success Function Test Comments Expected Outcome Expected Error Book Title Customer Add Book Negative Test Error Could not locate title in store Ruby on Rails Customer Add Book Success Pragmatic Unit Testing (C#) Function Test Comments Expected Outcome Expected Error Expect Cart Total Customer Check Cart Total Success 59.9
but... could this test a SOA? Test: Add Book Open http://localhost:3000/store VerifyTitle Book Store Find Ruby On Rails Type Quantity 1 Click CartB combined test case & test execution design Be ready for change
Gluing a datasheet to watir excel = WIN32OLE::new('excel.Application') computer says no... Use roo instead roo = open source, cross platform, ruby library for reading spreadsheets .xls, .ods, gDocs reads file content, works linux, mac no excel license needed, use openoffice
Gluing a datasheet to watir case ARGV[0] when "excel" @ss = Excel.new("watir.xls") when "gdocs" @ss = Google.new("0Au9u3") else @ss Openoffice.new("watir.ods") end end @ss.first_row.upto(@ss.last_row) do |row| # Run each test end
live demo
“ Share your knowledge. It ’ s a way to achieve immortality. ” ~ The Dalai Lama
0 comments
Post a comment