qa_robusta 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/.autotest +23 -0
  2. data/.gemtest +0 -0
  3. data/History.txt +6 -0
  4. data/Manifest.txt +101 -0
  5. data/README.txt +48 -0
  6. data/Rakefile +18 -0
  7. data/bin/qa_robusta +14 -0
  8. data/common/Rakefile +95 -0
  9. data/common/conf/monkey_patch.yaml +8 -0
  10. data/common/conf/monkey_patch.yaml.ex +10 -0
  11. data/common/lib/array.rb +9 -0
  12. data/common/lib/cache.rb +12 -0
  13. data/common/lib/constants.rb +35 -0
  14. data/common/lib/error_defns.rb +13 -0
  15. data/common/lib/format_html_tmp.html +34 -0
  16. data/common/lib/formatters.rb +18 -0
  17. data/common/lib/gem_helpers.rb +29 -0
  18. data/common/lib/gems/.svn/entries +43 -0
  19. data/common/lib/gems/cache/.svn/entries +28 -0
  20. data/common/lib/gems/doc/.svn/entries +28 -0
  21. data/common/lib/gems/gems/.svn/entries +28 -0
  22. data/common/lib/gems/installed/.svn/entries +40 -0
  23. data/common/lib/gems/installed/cache/.svn/entries +28 -0
  24. data/common/lib/gems/installed/doc/.svn/entries +28 -0
  25. data/common/lib/gems/installed/gems/.svn/entries +28 -0
  26. data/common/lib/gems/installed/specifications/.svn/entries +28 -0
  27. data/common/lib/gems/specifications/.svn/entries +28 -0
  28. data/common/lib/gen_suite_doc.rb +52 -0
  29. data/common/lib/load_test_data.rb +18 -0
  30. data/common/lib/monkey_patch.rb +149 -0
  31. data/common/lib/navigate_mech.rb +79 -0
  32. data/common/lib/update_element.rb +12 -0
  33. data/common/monkey_patches/mechanize.rb +589 -0
  34. data/common/monkey_patches/table.rb +363 -0
  35. data/common/monkey_patches/telnet.rb +420 -0
  36. data/common/monkey_patches/unit.rb +538 -0
  37. data/demo/demo_site.rb +38 -0
  38. data/demo/public/javascripts/jquery-1.6.2.min.js +18 -0
  39. data/demo/views/index.erb +35 -0
  40. data/lib/monkey_patch.rb +26 -0
  41. data/lib/qa_robusta.rb +3 -0
  42. data/mechanize_interface/conf/app.yaml +10 -0
  43. data/mechanize_interface/lib/agent.rb +18 -0
  44. data/mechanize_interface/lib/app_require.rb +19 -0
  45. data/mechanize_interface/lib/get_page.rb +20 -0
  46. data/mechanize_interface/lib/login.rb +30 -0
  47. data/mechanize_interface/lib/navigation_paths.rb +12 -0
  48. data/mechanize_interface/test/lib/mech_unit_test.rb +19 -0
  49. data/qa_observer/conf/dev_users.yaml +9 -0
  50. data/qa_observer/conf/development.yaml +3 -0
  51. data/qa_observer/conf/qa_observer_links.yaml +10 -0
  52. data/qa_observer/generators/site/site_generator.rb +61 -0
  53. data/qa_observer/generators/site/templates/base_urls.yaml.erb +6 -0
  54. data/qa_observer/generators/site/templates/create_flow.rb.erb +54 -0
  55. data/qa_observer/generators/site/templates/elements.rb.erb +61 -0
  56. data/qa_observer/generators/site/templates/html_elements.yaml +22 -0
  57. data/qa_observer/generators/site/templates/navigate.rb +32 -0
  58. data/qa_observer/generators/site/templates/reports.rb +7 -0
  59. data/qa_observer/generators/site/templates/users_list.yaml +21 -0
  60. data/qa_observer/generators/test_case/templates/test_case.rb.erb +62 -0
  61. data/qa_observer/generators/test_case/test_case_generator.rb +29 -0
  62. data/qa_observer/lib/doc.rb +103 -0
  63. data/qa_observer/lib/env_details.rb +2 -0
  64. data/qa_observer/lib/error_defns.rb +3 -0
  65. data/qa_observer/lib/form_helpers.rb +52 -0
  66. data/qa_observer/lib/reports.rb +7 -0
  67. data/qa_observer/lib/requires.rb +23 -0
  68. data/qa_observer/lib/system_test.rb +146 -0
  69. data/qa_observer/lib/test_extention.rb +29 -0
  70. data/qa_observer/lib/update_element.rb +12 -0
  71. data/qa_observer/lib/watir.rb +42 -0
  72. data/qa_observer/script/destroy +14 -0
  73. data/qa_observer/script/generate +14 -0
  74. data/qa_observer/sites/demo/conf/base_urls.yaml +6 -0
  75. data/qa_observer/sites/demo/conf/html_elements.yaml +22 -0
  76. data/qa_observer/sites/demo/conf/remote_machine.yaml +12 -0
  77. data/qa_observer/sites/demo/conf/users_list.yaml +21 -0
  78. data/qa_observer/sites/demo/elements/demo_elements.rb +9 -0
  79. data/qa_observer/sites/demo/flows/demo_flows.rb +37 -0
  80. data/qa_observer/sites/demo/helpers/.placeholder +0 -0
  81. data/qa_observer/sites/demo/lib/navigate.rb +32 -0
  82. data/qa_observer/sites/demo/lib/reports.rb +7 -0
  83. data/qa_observer/sites/demo/results/.placeholder +0 -0
  84. data/qa_observer/sites/demo/results/images/.placeholder +0 -0
  85. data/qa_observer/sites/demo/test_cases/home_page.rb +106 -0
  86. data/qa_observer/suites/demo_lg_chrome/lg.yaml +11 -0
  87. data/qa_observer/suites/demo_md_chrome/md.yaml +11 -0
  88. data/qa_observer/suites/demo_sm_chrome/sm.yaml +11 -0
  89. data/qa_observer/suites/init.rb +41 -0
  90. data/qa_observer/test_runner.rb +125 -0
  91. data/remote_unix/helpers/constants.rb +8 -0
  92. data/remote_unix/helpers/out_xforms.rb +48 -0
  93. data/remote_unix/lib/common.rb +52 -0
  94. data/remote_unix/lib/error_defn.rb +4 -0
  95. data/remote_unix/lib/general_unix.rb +308 -0
  96. data/remote_unix/lib/network_commands.rb +41 -0
  97. data/remote_unix/lib/network_info.rb +98 -0
  98. data/remote_unix/lib/postfix_commands.rb +87 -0
  99. data/remote_unix/lib/postfix_info.rb +30 -0
  100. data/remote_unix/lib/requires.rb +25 -0
  101. data/remote_unix/lib/scp.rb +22 -0
  102. data/remote_unix/lib/ssh.rb +46 -0
  103. data/test/test_qa_robusta.rb +8 -0
  104. metadata +219 -0
@@ -0,0 +1,29 @@
1
+ module TestExtention
2
+ def self.require_for_platform
3
+ @do_screenshot=true
4
+ if RUBY_PLATFORM =~ /win/i
5
+ require 'win32screenshot'
6
+ base_windows_bin="..\\..\\windows_bin\\"
7
+ ENV['PATH'] = "#{base_windows_bin}Mozilla_Firefox_309;#{base_windows_bin};#{base_windows_bin}lynx#{ENV['PATH']}"
8
+ # image magic will not work with jruby so not going to take shots
9
+ elsif RUBY_PLATFORM =~ /java/i
10
+ @do_screenshot=false
11
+ else
12
+ end
13
+ end
14
+
15
+ def self.screen_shot(method_name, at=nil, size = {:width => 800, :height => 600})
16
+ file = "#{File.expand_path(File.dirname(__FILE__))}/../tmp/images/#{$sequence}_#{Time.to_md5}_#{method_name}_#{at}.jpg"
17
+ @images << file
18
+ if at == 'post'
19
+ sleep 0.2
20
+ end
21
+ Watir::Screen.shot.resize(size[:width], size[:height]).write(file)
22
+ $sequence += 1
23
+ end
24
+
25
+ def self.get_images
26
+ @images
27
+ end
28
+ end
29
+
@@ -0,0 +1,12 @@
1
+ base = File.expand_path(File.dirname(__FILE__))
2
+
3
+ Dir.open("#{base}/firewatir").each { |i|
4
+ file = "#{base}/firewatir/#{i}"
5
+ next if File.directory?(file)
6
+ f = File.read(file)
7
+ f = f.gsub("< Element", "< Tmp::Element")
8
+ fd=File.open(file, 'w+')
9
+ fd.puts f
10
+ fd.close
11
+ }
12
+
@@ -0,0 +1,42 @@
1
+ module ImageWrap
2
+ def self.included(klass)
3
+ klass.instance_methods(false).each do |existing_method|
4
+ if existing_method == :click
5
+ wrap(klass, existing_method)
6
+ end
7
+ end
8
+ end
9
+
10
+ def self.wrap(klass, method)
11
+ klass.class_eval do
12
+ name = method.to_s
13
+ original_method = instance_method(name)
14
+
15
+ define_method(name) do |*args, &block|
16
+ TestExtention.screen_shot($current_test_method, 'pre')
17
+ result = original_method.bind(self).call(*args, &block)
18
+ TestExtention.screen_shot($current_test_method, 'post')
19
+ result
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ module Watir
26
+ module Screen
27
+ def self.shot
28
+ if RUBY_PLATFORM =~ /win/i
29
+ width, height, bitmap = Win32::Screenshot.desktop
30
+ img_lst = Magick::ImageList.new
31
+ img_lst.from_blob(bitmap)
32
+ else
33
+ Magick::Image.capture(silent=true, frame=false, descent=false,
34
+ screen=true, borders=false) { self.filename = 'root' }
35
+ end
36
+ end
37
+ end
38
+ class Element
39
+ include ImageWrap
40
+ end
41
+ end
42
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:taza, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ #RubiGen::Base.use_component_sources! [:taza, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,6 @@
1
+ :test:
2
+ :demo_home: http://127.0.0.1:9090
3
+ :development:
4
+ :demo_home: http://127.0.0.1:9090
5
+ :production:
6
+ :demo_home: http://127.0.0.1:9090
@@ -0,0 +1,22 @@
1
+ ---
2
+ :some_page:
3
+ :page_element1:
4
+ :type: text_field
5
+ :what: "watir's what parameter"
6
+ :what: "watir's how parameter"
7
+ :page_element2:
8
+ :type: text_field
9
+ :what: "watir's what parameter"
10
+ :what: "watir's how parameter"
11
+ :another_page:
12
+ :page_element1:
13
+ :type: text_field
14
+ :what: "watir's what parameter"
15
+ :what: "watir's how parameter"
16
+ :page_element2:
17
+ :type: text_field
18
+ :what: "watir's what parameter"
19
+ :what: "watir's how parameter"
20
+
21
+
22
+
@@ -0,0 +1,12 @@
1
+ :test:
2
+ :ssh_ip: 127.0.0.1
3
+ :ssh_user: cliff
4
+ :ssh_password:
5
+ :development:
6
+ :ssh_ip: 127.0.0.1
7
+ :ssh_user: cliff
8
+ :ssh_password:
9
+ :production:
10
+ :ssh_ip: 127.0.0.1
11
+ :ssh_user: cliff
12
+ :ssh_password:
@@ -0,0 +1,21 @@
1
+ :development:
2
+ :manager:
3
+ :user: 'user1'
4
+ :password: 'user1_password'
5
+ :employee:
6
+ :user: 'user2'
7
+ :password: 'user2_password'
8
+ :test:
9
+ :manager:
10
+ :user: 'user1'
11
+ :password: 'user1_password'
12
+ :employee:
13
+ :user: 'user2'
14
+ :password: 'user2_password'
15
+ :production:
16
+ :manager:
17
+ :user: 'user1'
18
+ :password: 'user1_password'
19
+ :employee:
20
+ :user: 'user2'
21
+ :password: 'user2_password'
@@ -0,0 +1,9 @@
1
+ module Demo
2
+ class HomePage < SystemTest
3
+ def initialize
4
+ element(:file_status) {$browser.div(:id, 'create_file_status')}
5
+ element(:create_file_text_field) {$browser.text_field(:id, 'create_file_name')}
6
+ element(:submit_create_file) {$browser.button(:id, 'create_file')}
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ base = File.expand_path(File.dirname(__FILE__))
2
+ require "#{$qa_observer_client}/lib/system_test"
3
+
4
+ class DemoFlows < SystemTest
5
+ # provide a means for the flow instance to access the elements.
6
+ # this is handy from the test case perspective as it will have
7
+ # access to the flow's but not the elements directly
8
+ attr_reader :home_page
9
+ def initialize
10
+ # NOTE: Define an instance of an element page
11
+ # in order for flow methods to be able to access
12
+ # elements. @login_page is an example the demo
13
+ # login method below utilizes. It's also a good idea
14
+ # to include in the attr_reader list so that the flows
15
+ # instance defined in a test class can access the element
16
+ # objects without the need to re-instantiate from the test
17
+
18
+ @home_page = Demo::HomePage.new
19
+ end
20
+
21
+ =begin
22
+ Best Practice: Anytime arriving at a page it's a best practice to wait for
23
+ the last element on the page to load(wait_for).
24
+ =end
25
+ def home
26
+ $browser.goto($test_data[:base_urls][$test_environment][:demo_home])
27
+ wait_for(5) { @home_page.submit_create_file.exists? }
28
+ end
29
+
30
+ def create_file(file_name='')
31
+ home
32
+ @home_page.create_file_text_field.set(file_name)
33
+ @home_page.submit_create_file.click
34
+ wait_for(2) { @home_page.file_status.text != '' }
35
+ end
36
+ end
37
+
@@ -0,0 +1,32 @@
1
+ class Navigate
2
+ attr_reader :browser
3
+ def initialize(browser)
4
+ @browser = browser
5
+ end
6
+ def go(nav_path=[])
7
+ raise ArgumentError if nav_path.class != Array || nav_path.nitems < 1
8
+ nav_path.each { |item|
9
+ case item[:type]
10
+ when 'link'
11
+ exec = "@browser.link(#{item[:how]}, #{item[:what]}).#{item[:action]}"
12
+ eval exec
13
+ when 'text_field'
14
+ if item.has_key?(:value)
15
+ # escape ' in item[:value] as it's used for quoted string in the set
16
+ #item[:value].gsub(/'/, /\'/)
17
+ exec = "@browser.text_field(#{item[:how]}, #{item[:what]}).#{item[:action]}('#{item[:value]}')"
18
+ eval exec
19
+ end
20
+ when 'check_box'
21
+ # escape ' in item[:value] as it's used for quoted string in the set
22
+ #item[:value].gsub(/'/, /\'/)
23
+ exec = "@browser.checkbox(#{item[:how]}, #{item[:what]}).#{item[:action]}"
24
+ eval exec
25
+ when 'submit'
26
+ exec = "@browser.button(#{item[:how]}, #{item[:what]}).#{item[:action]}"
27
+ eval exec
28
+
29
+ end
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ require 'pdf/writer'
2
+
3
+ module BuildReport
4
+ def pdf(report)
5
+
6
+ end
7
+ end
@@ -0,0 +1,106 @@
1
+ base = File.expand_path(File.dirname(__FILE__))
2
+
3
+ # If the user is executing the test case stand alone
4
+ # without an agent we need to set a reference to
5
+ # for where to find the qa_observer_client as well as let
6
+ # the qa_observer_client know where the test case directory is
7
+ # URGENT: DO NOT MODIFY
8
+ unless $qa_observer_client
9
+ TEST_CASE_DIR = "#{base}"
10
+ $qa_observer_client = File.expand_path("#{base}/../../..")
11
+ end
12
+ # END OF DO NOT MODIFY
13
+
14
+ require "#{$qa_observer_client}/lib/system_test"
15
+ require "#{$qa_observer_client}/lib/env_details.rb"
16
+
17
+ class HomePage < SystemTest
18
+ def setup
19
+ # if the user hasn't provided the environment as an input
20
+ # parameter to the interpreter default to :test
21
+ $test_environment ||= :test
22
+ super
23
+ @remote_unix = RemoteUnix::GeneralUnix.new(:host => $test_data[:remote_machine][$test_environment][:ssh_ip],
24
+ :user => $test_data[:remote_machine][$test_environment][:ssh_user],
25
+ :password => $test_data[:remote_machine][$test_environment][:ssh_password])
26
+
27
+ @demo_flows = DemoFlows.new
28
+ end
29
+
30
+ def teardown
31
+ # NOTE: Place all items you wish to do at after each test method
32
+ # in the unless @skip section before the $browser.close. DO NOT
33
+ # remove this section as it's critical if the test class is executed
34
+ # by an agent.
35
+ unless @skip
36
+ $browser.close if $browser
37
+ end
38
+
39
+ super
40
+ end
41
+
42
+ # TODO: add test methods
43
+ # don't forget to update the documentation associated with each test method,
44
+ # by placing an rdoc style comment in plain text. The documentation will be
45
+ # included in the report for each execution.
46
+
47
+ =begin rdoc
48
+ Test Purpose:
49
+ After the user arrives on the home page verify the following elements exists:
50
+ * Div with id = create_file_status
51
+ * Text field with id= create_file_name
52
+ * Submit button with id = create_file
53
+
54
+ Verify the user can enter a value in the create_file_name text field
55
+ =end
56
+ def test_home_elements
57
+ @demo_flows.home
58
+ assert_equal $test_data[:base_urls][$test_environment][:demo_home].gsub(/\/$/, ''), $browser.url.gsub(/\/$/, '')
59
+ assert @demo_flows.home_page.file_status.exists?
60
+ assert @demo_flows.home_page.create_file_text_field.exists?
61
+ assert @demo_flows.home_page.submit_create_file.exists?
62
+ @demo_flows.home_page.create_file_text_field.set('blah')
63
+ assert_equal 'blah', @demo_flows.home_page.create_file_text_field.value
64
+ end
65
+
66
+ =begin rdoc
67
+ Test Purpose:
68
+ After the user arrives on the home page verify the create file feature
69
+
70
+ Steps:
71
+ * Naviage to the home page
72
+ * Enter a file name in the Create Tmp File text field
73
+ * Click the Create Tmp File submit button
74
+ * Verify a message is displayed on the home page that the file was created
75
+ * Login to the remote machine and verify that the file exists
76
+ =end
77
+ def test_file_created
78
+ @demo_flows.create_file('blah')
79
+ assert_equal 'file created', @demo_flows.home_page.file_status.text
80
+ assert @remote_unix.file_exists?('/tmp/blah')
81
+ end
82
+
83
+ =begin rdoc
84
+ Test Purpose:
85
+ After the user arrives on the home page verify when no file name is provided a
86
+ message is provided informing the user to provide a file name
87
+
88
+ Steps:
89
+ * Naviage to the home page
90
+ * Click the Create Tmp File submit button
91
+ * Verify a message is displayed on the home page to provide a file name
92
+ * Login to the remote machine hosting the web site and ensure that no file was
93
+ created
94
+ =end
95
+ def test_error_message_with_no_file_name
96
+ remote_tmp_files_pre = @remote_unix.ls('/tmp')
97
+ @demo_flows.create_file
98
+ assert_equal 'Please provide a file name', @demo_flows.home_page.file_status.text
99
+ remote_tmp_files_post = @remote_unix.ls('/tmp')
100
+ assert_equal remote_tmp_files_pre, remote_tmp_files_post
101
+ end
102
+
103
+ end
104
+
105
+
106
+
@@ -0,0 +1,11 @@
1
+ ---
2
+ # global setup items, can override on a per suite basis
3
+ :default:
4
+ :browser: chrome
5
+
6
+ :suites:
7
+ - :site: demo
8
+ :test_case_file: home_page.rb
9
+ :environment: production
10
+ :methods_to_execute: test_error_message_with_no_file_name
11
+
@@ -0,0 +1,11 @@
1
+ ---
2
+ # global setup items, can override on a per suite basis
3
+ :default:
4
+ :browser: chrome
5
+
6
+ :suites:
7
+ - :site: demo
8
+ :test_case_file: home_page.rb
9
+ :environment: production
10
+ :methods_to_execute: test_file_created
11
+
@@ -0,0 +1,11 @@
1
+ ---
2
+ # global setup items, can override on a per suite basis
3
+ :default:
4
+ :browser: chrome
5
+
6
+ :suites:
7
+ - :site: demo
8
+ :test_case_file: home_page.rb
9
+ :environment: production
10
+ :methods_to_execute: test_home_elements
11
+
@@ -0,0 +1,41 @@
1
+ require 'yaml'
2
+
3
+ module SuiteHelper
4
+ def self.exec(suite, junit=false, proxy=nil)
5
+ base = File.expand_path(File.dirname(__FILE__))
6
+ cfg = YAML::load_file(suite)
7
+
8
+ optional_options = ''
9
+
10
+ if proxy
11
+ optional_options += " --proxy=#{proxy}"
12
+ end
13
+
14
+ if junit
15
+ optional_options += " --format=junit"
16
+ end
17
+
18
+ cfg[:suites].each { |test|
19
+ puts "looking at test: #{test.inspect}"
20
+
21
+ # if the current test for the suite has a browser use that
22
+ # else take default browser
23
+ if test.has_key?(:browser)
24
+ browser = test[:browser]
25
+ else
26
+ browser = cfg[:default][:browser]
27
+ end
28
+
29
+ params = "--site=#{test[:site]} --file_name=#{test[:test_case_file]} --execute_methods=#{test[:methods_to_execute]} --browser=#{browser} --environment=#{test[:environment]} #{optional_options}"
30
+
31
+ puts "executing test_runner with options: #{params}"
32
+ out = `ruby #{base}/../test_runner.rb #{params}`
33
+ puts out
34
+
35
+ }
36
+ end
37
+ end
38
+
39
+ suite = ARGV[0]
40
+ raise ArgumentError unless File.exists? suite
41
+ SuiteHelper.exec suite