tddium_reporting 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2011 Solano Labs All Rights Reserved
2
+ require File.expand_path(File.dirname(__FILE__) + "/tddium_reporting/system_capture")
3
+
4
+ runner = defined?(RSpec) ? RSpec : Spec::Runner
5
+
6
+ if ENV["TDDIUM"]
7
+ runner.configure do |config|
8
+ config.after(:each) do
9
+ if defined?(selenium_driver)
10
+ begin
11
+ reporting = TddiumReporting::SystemCapture.new(selenium_driver, self)
12
+ reporting.capture_system_state
13
+ STDOUT.puts "%%TDDIUM_EXAMPLE_ID:#{reporting.example_id}%%"
14
+ rescue Exception => e
15
+ STDERR.puts "Problem while capturing system state" + e
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,80 @@
1
+ # Copyright (c) 2011 Solano Labs All Rights Reserved
2
+ #
3
+ require 'base64'
4
+
5
+ module TddiumReporting
6
+ class SystemCapture
7
+ attr_reader :example_id
8
+
9
+ def initialize(selenium_driver, example)
10
+ @selenium_driver = selenium_driver
11
+ @example = example
12
+ @example_id = Digest::MD5.hexdigest(example.inspect)
13
+ @things = {:html_capture => "html",
14
+ :system_screenshot => "png",
15
+ :page_screenshot => "png",
16
+ :remote_control_logs => "log"}
17
+ end
18
+
19
+ def path_for(thing)
20
+ File.expand_path("~/results/#{ENV['TDDIUM_SESSION_ID']}/#{ENV['TDDIUM_TEST_EXEC_ID']}/#{@example_id}-#{thing}.#{@things[thing]}")
21
+ end
22
+
23
+ def capture_system_state
24
+ # Selenium RC seems to 'freeze' every so often when calling
25
+ # getHTMLSource, especially when DeepTest timeout is low, I need to investigate...
26
+ # Set deeptest :timeout_in_seconds => 30 to see it happen
27
+ begin
28
+ retrieve_remote_control_logs
29
+ rescue Exception => e
30
+ STDERR.puts "WARNING: Could not retrieve remote control logs: #{e}"
31
+ end
32
+ begin
33
+ capture_html_snapshot
34
+ rescue Exception => e
35
+ STDERR.puts "WARNING: Could not capture HTML snapshot: #{e}"
36
+ end
37
+ begin
38
+ capture_page_screenshot
39
+ rescue Exception => e
40
+ STDERR.puts "WARNING: Could not capture page screenshot: #{e}"
41
+ end
42
+ begin
43
+ capture_system_screenshot
44
+ rescue Exception => e
45
+ STDERR.puts "WARNING: Could not capture system screenshot: #{e}"
46
+ end
47
+ end
48
+
49
+ def capture_html_snapshot
50
+ # Skipping HTML Snapshot retrieval, if there is no current Selenium session
51
+ return unless @selenium_driver.session_started?
52
+
53
+ html = @selenium_driver.get_html_source
54
+ File.open(path_for(:html_capture), "w") { |f| f.write html }
55
+ end
56
+
57
+ def capture_system_screenshot
58
+ @selenium_driver.window_maximize if @selenium_driver.session_started?
59
+
60
+ encodedImage = @selenium_driver.capture_screenshot_to_string
61
+ pngImage = Base64.decode64(encodedImage)
62
+ File.open(path_for(:system_screenshot), "wb") { |f| f.write pngImage }
63
+ end
64
+
65
+ def capture_page_screenshot
66
+ return unless @selenium_driver.chrome_backend? && @selenium_driver.session_started?
67
+
68
+ encodedImage = @selenium_driver.capture_entire_page_screenshot_to_string("")
69
+ pngImage = Base64.decode64(encodedImage)
70
+ File.open(path_for(:page_screenshot), "wb") { |f| f.write pngImage }
71
+ end
72
+
73
+ def retrieve_remote_control_logs
74
+ logs = @selenium_driver.retrieve_last_remote_control_logs
75
+ File.open(path_for(:remote_control_logs), "w") { |f| f.write logs }
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -0,0 +1,4 @@
1
+ # Copyright (c) 2011 Solano Labs All Rights Reserved
2
+ module TddiumReporting
3
+ VERSION = '0.0.3'
4
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tddium_reporting
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - Solano Labs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-08-01 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ description: Tddium reporting utilities. Includes support for tddium selenium screencaptures
39
+ email:
40
+ - info@tddium.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - lib/tddium_reporting.rb
49
+ - lib/tddium_reporting/system_capture.rb
50
+ - lib/tddium_reporting/version.rb
51
+ has_rdoc: true
52
+ homepage: http://www.tddium.com/
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project: tddium
75
+ rubygems_version: 1.6.2
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Tddium Reporting Utilities
79
+ test_files: []
80
+