Class: Applitools::TestResults
- Inherits:
-
Object
- Object
- Applitools::TestResults
show all
- Defined in:
- lib/applitools/core/test_results.rb
Defined Under Namespace
Classes: AccessibilityStatus
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(init_results = {}) ⇒ TestResults
Returns a new instance of TestResults.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/applitools/core/test_results.rb', line 22
def initialize(init_results = {})
environment = init_results[:environment] || {}
@renderer = Applitools::Utils.deep_stringify_keys(Applitools::Utils.underscore_hash_keys(environment[:requested]))
@browser_info = JSON.parse(@renderer.to_json, object_class: OpenStruct)
results = Applitools::Utils.deep_stringify_keys(init_results[:result] ? init_results[:result] : init_results)
@original_results = results
@steps = results.fetch('steps', 0)
@matches = results.fetch('matches', 0)
@mismatches = results.fetch('mismatches', 0)
@missing = results.fetch('missing', 0)
@status = results.fetch('status', 0)
@is_new = results.fetch('isNew', nil)
@url = results.fetch('url', nil)
end
|
Instance Attribute Details
#browser_info ⇒ Object
Returns the value of attribute browser_info.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def browser_info
@browser_info
end
|
#is_new ⇒ Object
Returns the value of attribute is_new.
19
20
21
|
# File 'lib/applitools/core/test_results.rb', line 19
def is_new
@is_new
end
|
#matches ⇒ Object
Returns the value of attribute matches.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def matches
@matches
end
|
#mismatches ⇒ Object
Returns the value of attribute mismatches.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def mismatches
@mismatches
end
|
#missing ⇒ Object
Returns the value of attribute missing.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def missing
@missing
end
|
#original_results ⇒ Object
Returns the value of attribute original_results.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def original_results
@original_results
end
|
#renderer ⇒ Object
Returns the value of attribute renderer.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def renderer
@renderer
end
|
#screenshot ⇒ Object
Returns the value of attribute screenshot.
19
20
21
|
# File 'lib/applitools/core/test_results.rb', line 19
def screenshot
@screenshot
end
|
#status ⇒ Object
Returns the value of attribute status.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def status
@status
end
|
#steps ⇒ Object
Returns the value of attribute steps.
20
21
22
|
# File 'lib/applitools/core/test_results.rb', line 20
def steps
@steps
end
|
#url ⇒ Object
Returns the value of attribute url.
19
20
21
|
# File 'lib/applitools/core/test_results.rb', line 19
def url
@url
end
|
Instance Method Details
#==(other) ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/applitools/core/test_results.rb', line 89
def ==(other)
if other.is_a? self.class
result = true
%w(is_new url steps matches mismatches missing).each do |field|
result &&= send(field) == other.send(field)
end
return result if result
end
false
end
|
#aborted? ⇒ Boolean
61
62
63
|
# File 'lib/applitools/core/test_results.rb', line 61
def aborted?
original_results['isAborted'] || !errors.nil?
end
|
#api_session_url ⇒ Object
65
66
67
|
# File 'lib/applitools/core/test_results.rb', line 65
def api_session_url
original_results['apiUrls']['session']
end
|
#app_name ⇒ Object
81
82
83
|
# File 'lib/applitools/core/test_results.rb', line 81
def app_name
original_results['appName']
end
|
#different? ⇒ Boolean
57
58
59
|
# File 'lib/applitools/core/test_results.rb', line 57
def different?
original_results['isDifferent']
end
|
#errors ⇒ Object
77
78
79
|
# File 'lib/applitools/core/test_results.rb', line 77
def errors
original_results['error']
end
|
#failed? ⇒ Boolean
45
46
47
|
# File 'lib/applitools/core/test_results.rb', line 45
def failed?
status == 'Failed'
end
|
#name ⇒ Object
73
74
75
|
# File 'lib/applitools/core/test_results.rb', line 73
def name
original_results['name']
end
|
#new? ⇒ Boolean
53
54
55
|
# File 'lib/applitools/core/test_results.rb', line 53
def new?
original_results['isNew']
end
|
#passed? ⇒ Boolean
Also known as:
is_passed, as_expected?
41
42
43
|
# File 'lib/applitools/core/test_results.rb', line 41
def passed?
status == 'Passed'
end
|
#secret_token ⇒ Object
69
70
71
|
# File 'lib/applitools/core/test_results.rb', line 69
def secret_token
original_results['secretToken']
end
|
#session_accessibility_status ⇒ Object
85
86
87
|
# File 'lib/applitools/core/test_results.rb', line 85
def session_accessibility_status
@accessibility_status ||= original_results['accessibilityStatus'] && AccessibilityStatus.new(original_results['accessibilityStatus'] || {})
end
|
#test_results ⇒ Object
37
38
39
|
# File 'lib/applitools/core/test_results.rb', line 37
def test_results
self
end
|
#to_s(advanced = false) ⇒ Object
104
105
106
107
108
109
110
111
112
|
# File 'lib/applitools/core/test_results.rb', line 104
def to_s(advanced = false)
is_new_str = ''
is_new_str = is_new ? 'New test' : 'Existing test' unless is_new.nil?
return @original_results.to_yaml if advanced
"#{is_new_str} [ steps: #{steps}, matches: #{matches}, mismatches: #{mismatches}, missing: #{missing} ], " \
"URL: #{url}"
end
|
#unresolved? ⇒ Boolean
49
50
51
|
# File 'lib/applitools/core/test_results.rb', line 49
def unresolved?
status == 'Unresolved'
end
|