testability-driver 0.9.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
- data/lib/tdriver/base/behaviour/factory.rb +229 -209
- data/lib/tdriver/base/errors.rb +3 -0
- data/lib/tdriver/base/state_object.rb +11 -20
- data/lib/tdriver/base/sut/controller.rb +4 -4
- data/lib/tdriver/base/sut/factory.rb +205 -170
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
- data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
- data/lib/tdriver/base/sut/sut.rb +41 -33
- data/lib/tdriver/base/test_object/abstract.rb +26 -3
- data/lib/tdriver/base/test_object/adapter.rb +399 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
- data/lib/tdriver/base/test_object/cache.rb +132 -0
- data/lib/tdriver/base/test_object/factory.rb +677 -426
- data/lib/tdriver/base/test_object/factory_new.rb +202 -0
- data/lib/tdriver/base/test_object/identificator.rb +24 -17
- data/lib/tdriver/base/test_object/loader.rb +9 -3
- data/lib/tdriver/base/test_object/verification.rb +181 -0
- data/lib/tdriver/loader.rb +1 -1
- data/lib/tdriver/report/report.rb +2 -0
- data/lib/tdriver/report/report_api.rb +4 -4
- data/lib/tdriver/report/report_creator.rb +29 -3
- data/lib/tdriver/report/report_data_presentation.rb +7 -3
- data/lib/tdriver/report/report_execution_statistics.rb +80 -21
- data/lib/tdriver/report/report_javascript.rb +192 -0
- data/lib/tdriver/report/report_test_case_run.rb +22 -0
- data/lib/tdriver/report/report_test_run.rb +62 -55
- data/lib/tdriver/report/report_writer.rb +57 -56
- data/lib/tdriver/tdriver.rb +14 -41
- data/lib/tdriver/util/common/error.rb +1 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +12 -6
- data/lib/tdriver/util/common/gem.rb +2 -1
- data/lib/tdriver/util/common/hash.rb +152 -0
- data/lib/tdriver/util/common/kernel.rb +49 -34
- data/lib/tdriver/util/common/loader.rb +21 -17
- data/lib/tdriver/util/common/numeric.rb +39 -0
- data/lib/tdriver/util/common/object.rb +115 -0
- data/lib/tdriver/util/common/string.rb +55 -2
- data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
- data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
- data/lib/tdriver/util/hooking.rb +2 -2
- data/lib/tdriver/util/loader.rb +2 -2
- data/lib/tdriver/util/localisation/localisation.rb +277 -18
- data/lib/tdriver/util/logger.rb +142 -13
- data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
- data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
- data/lib/tdriver/util/recorder.rb +17 -12
- data/lib/tdriver/util/user_data/user_data.rb +3 -2
- data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
- data/lib/tdriver/util/xml/abstraction.rb +7 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/loader.rb +8 -2
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +35 -22
- data/lib/tdriver/version.rb +1 -1
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
- data/lib/tdriver-devtools/doc/generate.rb +31 -6
- data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
- data/lib/tdriver.rb +0 -3
- data/xml/behaviours/generic.xml +1 -1
- data/xml/defaults/generic.xml +4 -90
- data/xml/templates/generic.xml +33 -25
- metadata +21 -29
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
- data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
@@ -0,0 +1,202 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module TDriver
|
21
|
+
|
22
|
+
class TestObjectFactory
|
23
|
+
|
24
|
+
attr_accessor :timeout, :retry_interval, :test_object_adapter
|
25
|
+
|
26
|
+
def initialize( test_object_adapter )
|
27
|
+
|
28
|
+
#@timeout = 5
|
29
|
+
|
30
|
+
#@retry_interval = 1
|
31
|
+
|
32
|
+
@test_object_adapter = test_object_adapter
|
33
|
+
|
34
|
+
@timeout = MobyUtil::Parameter[ :synchronization_timeout, "20" ].to_f
|
35
|
+
|
36
|
+
@retry_interval = MobyUtil::Parameter[ :synchronization_retry_interval, "1" ].to_f
|
37
|
+
|
38
|
+
end # initialize
|
39
|
+
|
40
|
+
def get_objects( source_data, rules, &block )
|
41
|
+
|
42
|
+
# __multiple_objects
|
43
|
+
# __all_children
|
44
|
+
#
|
45
|
+
|
46
|
+
#TDriver::TestObjectIdentificator.new( creation_hash )
|
47
|
+
# {:type=>"application", :name=>"calculator"}
|
48
|
+
|
49
|
+
test_object_attributes = rules[ :attributes ]
|
50
|
+
|
51
|
+
dynamic_attributes = strip_dynamic_attributes!( test_object_attributes )
|
52
|
+
|
53
|
+
# add keys from rules to dynamic attribute filter list -- to avoid IRB bug
|
54
|
+
MobyUtil::DynamicAttributeFilter.instance.add_attributes( rules.keys )
|
55
|
+
|
56
|
+
#p dynamic_attributes
|
57
|
+
#p rules
|
58
|
+
|
59
|
+
refresh = false
|
60
|
+
|
61
|
+
MobyUtil::Retryable.until(
|
62
|
+
|
63
|
+
:timeout => @timeout,
|
64
|
+
:interval => @retry_interval,
|
65
|
+
:exception => [ MobyBase::TestObjectNotFoundError, MobyBase::MultipleTestObjectsIdentifiedError ]
|
66
|
+
|
67
|
+
){
|
68
|
+
|
69
|
+
# refresh source data if refresh flag is set to true
|
70
|
+
source_data = yield( source_data ) if refresh
|
71
|
+
|
72
|
+
# set refresh flag to true
|
73
|
+
refresh = true
|
74
|
+
|
75
|
+
matches, rule = @test_object_adapter.get_objects( source_data, test_object_attributes )
|
76
|
+
|
77
|
+
# create string representation of hash merged with and dynamic attributes
|
78
|
+
rules_string = test_object_attributes.merge( dynamic_attributes ).inspect
|
79
|
+
|
80
|
+
# raise exception if multiple matches found
|
81
|
+
Kernel::raise MobyBase::MultipleTestObjectsIdentifiedError.new(
|
82
|
+
|
83
|
+
"Multiple test objects found with rule: #{ rules_string }"
|
84
|
+
|
85
|
+
) if !dynamic_attributes.has_key?( :__index ) and (!( rules[ :multiple_objects ] || false ) and matches.size > 1)
|
86
|
+
|
87
|
+
# raise exception if no matches found
|
88
|
+
Kernel::raise MobyBase::TestObjectNotFoundError.new(
|
89
|
+
|
90
|
+
"Cannot find object with rule: #{ rules_string }"
|
91
|
+
|
92
|
+
) if matches.size.zero?
|
93
|
+
|
94
|
+
# ... or proceed if no exceptions raised
|
95
|
+
|
96
|
+
# sort elements if required by caller
|
97
|
+
# @test_object_adapter.sort_elements....
|
98
|
+
|
99
|
+
# return only one element if index given
|
100
|
+
matches = [ matches[ dynamic_attributes[ :__index ] ] ] if dynamic_attributes.has_key?( :__index )
|
101
|
+
|
102
|
+
# return array of matching test object(s)
|
103
|
+
make_test_objects( matches, rules )
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
end # get_objects
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def make_test_objects( matches, rules )
|
112
|
+
|
113
|
+
#p rules
|
114
|
+
|
115
|
+
sut = rules[ :sut ]
|
116
|
+
|
117
|
+
# return array of matching test object(s)
|
118
|
+
matches.collect{ | source_data |
|
119
|
+
|
120
|
+
# get test object type from xml
|
121
|
+
object_type = @test_object_adapter.test_object_attribute( 'type', source_data )
|
122
|
+
|
123
|
+
# create new test object instance
|
124
|
+
test_object = MobyBase::TestObject.new(
|
125
|
+
|
126
|
+
# test object factory
|
127
|
+
self,
|
128
|
+
|
129
|
+
# associated sut
|
130
|
+
sut,
|
131
|
+
|
132
|
+
# associated parent object; either test object, application or sut
|
133
|
+
rules[ :parent_object ],
|
134
|
+
|
135
|
+
# test object xml data
|
136
|
+
source_data
|
137
|
+
|
138
|
+
)
|
139
|
+
|
140
|
+
# apply object composition behaviour to test object
|
141
|
+
test_object.extend( MobyBehaviour::ObjectBehaviourComposition )
|
142
|
+
|
143
|
+
# TODO: behaviours should be applied by using BehaviourFactory directly
|
144
|
+
# apply behaviours to test object
|
145
|
+
test_object.apply_behaviour!(
|
146
|
+
:object_type => [ '*', object_type ],
|
147
|
+
:sut_type => [ '*', sut.ui_type ],
|
148
|
+
:input_type => [ '*', sut.input.to_s ],
|
149
|
+
:version => [ '*', sut.ui_version ]
|
150
|
+
)
|
151
|
+
|
152
|
+
# create child accessors
|
153
|
+
@test_object_adapter.create_child_accessors!( test_object, source_data )
|
154
|
+
|
155
|
+
# TODO: call verification block if defined (verify_ui_dump)
|
156
|
+
|
157
|
+
# # do not make test object verifications if we are operating on the
|
158
|
+
# # base sut itself (allow run to pass)
|
159
|
+
# unless parent.kind_of?( MobyBase::SUT )
|
160
|
+
# verify_ui_dump( sut ) unless sut.verify_blocks.empty?
|
161
|
+
# end
|
162
|
+
|
163
|
+
# pass test object with behaviours as result
|
164
|
+
test_object
|
165
|
+
|
166
|
+
}
|
167
|
+
|
168
|
+
end # make_test_objects
|
169
|
+
|
170
|
+
def strip_dynamic_attributes!( hash )
|
171
|
+
|
172
|
+
# remove dynamic attributes from hash and return as result
|
173
|
+
Hash[
|
174
|
+
|
175
|
+
# iterate through each hash key
|
176
|
+
hash.select{ | key, value |
|
177
|
+
|
178
|
+
# dynamic attribute name has "__" prefix
|
179
|
+
if key.to_s =~ /^__/
|
180
|
+
|
181
|
+
# remove dynamic attribute key from hash
|
182
|
+
hash.delete( key )
|
183
|
+
|
184
|
+
# add to hash
|
185
|
+
true
|
186
|
+
|
187
|
+
else
|
188
|
+
|
189
|
+
# do not add to hash
|
190
|
+
false
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
}
|
195
|
+
|
196
|
+
]
|
197
|
+
|
198
|
+
end # strip_dynamic_attributes!
|
199
|
+
|
200
|
+
end # TestObjectFactory
|
201
|
+
|
202
|
+
end # TDriver
|
@@ -81,28 +81,28 @@ module MobyBase
|
|
81
81
|
# Sort XML nodeset of test objects with layout direction
|
82
82
|
def sort_elements_by_xy_layout!( nodeset, layout_direction = "LeftToRight" )
|
83
83
|
|
84
|
-
attribute_pattern = "./attributes/attribute[@name='%s']/value"
|
84
|
+
attribute_pattern = "./attributes/attribute[@name='%s']/value/text()"
|
85
85
|
|
86
86
|
# collect only nodes that has x_absolute and y_absolute attributes
|
87
87
|
nodeset.collect!{ | node |
|
88
88
|
|
89
|
-
node unless node.
|
89
|
+
node unless node.at_xpath( attribute_pattern % 'x_absolute' ).to_s.empty? || node.at_xpath( attribute_pattern % 'y_absolute' ).to_s.empty?
|
90
90
|
|
91
|
-
}.compact!.sort!{ |
|
91
|
+
}.compact!.sort!{ | element_a, element_b |
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
element_a_x = element_a.at_xpath( attribute_pattern % 'x_absolute' ).content.to_i
|
94
|
+
element_a_y = element_a.at_xpath( attribute_pattern % 'y_absolute' ).content.to_i
|
95
95
|
|
96
|
-
|
97
|
-
|
96
|
+
element_b_x = element_b.at_xpath( attribute_pattern % 'x_absolute' ).content.to_i
|
97
|
+
element_b_y = element_b.at_xpath( attribute_pattern % 'y_absolute' ).content.to_i
|
98
98
|
|
99
99
|
if ( layout_direction =~ /LeftToRight/i )
|
100
100
|
|
101
|
-
(
|
101
|
+
( element_a_y == element_b_y ) ? ( element_a_x <=> element_b_x ) : ( element_a_y <=> element_b_y )
|
102
102
|
|
103
103
|
elsif ( layout_direction =~ /RightToLeft/i )
|
104
104
|
|
105
|
-
(
|
105
|
+
( element_a_y == element_b_y ) ? ( element_b_x <=> element_a_x ) : ( element_a_y <=> element_b_y )
|
106
106
|
|
107
107
|
else
|
108
108
|
|
@@ -393,6 +393,7 @@ module MobyBase
|
|
393
393
|
|
394
394
|
end
|
395
395
|
|
396
|
+
=begin
|
396
397
|
## Returns array of element nodes
|
397
398
|
def sort_elements_by_xy_layout( element_set, layout_direction = "LeftToRight" )
|
398
399
|
|
@@ -413,19 +414,20 @@ module MobyBase
|
|
413
414
|
# Sort remaining by layout direction and up to down
|
414
415
|
# Requires .to_a to return an array of MobyUtil::XML::Elements
|
415
416
|
element_set.to_a.sort!{ |a, b|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
417
|
+
element_a_x = a.xpath("./attributes/attribute[@name = 'x_absolute']/value").first.content.to_i
|
418
|
+
element_a_y = a.xpath("./attributes/attribute[@name = 'y_absolute']/value").first.content.to_i
|
419
|
+
element_b_x = b.xpath("./attributes/attribute[@name = 'x_absolute']/value").first.content.to_i
|
420
|
+
element_b_y = b.xpath("./attributes/attribute[@name = 'y_absolute']/value").first.content.to_i
|
420
421
|
if ( layout_direction.downcase == "LeftToRight".downcase )
|
421
|
-
(
|
422
|
+
( element_a_y == element_b_y ) ? ( element_a_x <=> element_b_x ) : ( element_a_y <=> element_b_y )
|
422
423
|
elsif ( layout_direction.downcase == "RightToLeft".downcase )
|
423
|
-
(
|
424
|
+
( element_a_y == element_b_y ) ? ( element_b_x <=> element_a_x ) : ( element_a_y <=> element_b_y )
|
424
425
|
else
|
425
426
|
Kernel::raise ArgumentError.new("Unexpected layout direction: " + layout_direction)
|
426
427
|
end
|
427
428
|
}
|
428
429
|
end
|
430
|
+
=end
|
429
431
|
|
430
432
|
# Function to identify an object from tasMessage xml content
|
431
433
|
#
|
@@ -439,7 +441,9 @@ module MobyBase
|
|
439
441
|
# ArgumentError:: if 'from_xml_element' is not of type MobyUtil::XML::Element
|
440
442
|
def find_object_data( from_xml_element, layout_direction = nil )
|
441
443
|
|
442
|
-
|
444
|
+
from_xml_element.check_type( MobyUtil::XML::Element, "Wrong argument type $1 for XML element (expected $2)" )
|
445
|
+
|
446
|
+
#Kernel::raise ArgumentError.new( "Wrong argument type %s for argument 'xml_element' (expected MobyUtil::XML::Element)" % from_xml_element.class ) unless from_xml_element.kind_of?( MobyUtil::XML::Element )
|
443
447
|
|
444
448
|
xpath = get_xpath_to_identify( from_xml_element )
|
445
449
|
|
@@ -475,7 +479,10 @@ module MobyBase
|
|
475
479
|
# TestObjectNotFoundError:: if no TestObject can be identified
|
476
480
|
# ArgumentError:: if 'from_xml_element' is not of type MobyUtil::XML::Element
|
477
481
|
def find_multiple_object_data( from_xml_element, find_all_children, layout_direction = nil )
|
478
|
-
|
482
|
+
|
483
|
+
from_xml_element.check_type( MobyUtil::XML::Element, "Wrong argument type $1 for XML element (expected $2)" )
|
484
|
+
|
485
|
+
#Kernel::raise ArgumentError.new( "Wrong argument type %s for argument 'xml_element' (expected MobyUtil::XML::Element)" % from_xml_element.class ) unless from_xml_element.kind_of?( MobyUtil::XML::Element )
|
479
486
|
|
480
487
|
element_set = from_xml_element.xpath( xpath = get_xpath_to_identify( from_xml_element ,nil,find_all_children) )
|
481
488
|
ret = Array.new
|
@@ -17,9 +17,6 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
20
|
# load test object abstract class
|
24
21
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'abstract' ) )
|
25
22
|
|
@@ -29,6 +26,15 @@ require File.expand_path( File.join( File.dirname( __FILE__ ), 'identificator' )
|
|
29
26
|
# load test object factory
|
30
27
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'factory' ) )
|
31
28
|
|
29
|
+
# load test object cache
|
30
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'cache' ) )
|
31
|
+
|
32
|
+
# load test object adapter
|
33
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'adapter' ) )
|
34
|
+
|
35
|
+
# load verify ui module
|
36
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'verification' ) )
|
37
|
+
|
32
38
|
# load test object behaviours
|
33
39
|
MobyUtil::FileHelper.load_modules( File.expand_path( File.join( File.dirname( __FILE__ ), 'behaviours' ) ) )
|
34
40
|
|
@@ -0,0 +1,181 @@
|
|
1
|
+
|
2
|
+
module TDriver
|
3
|
+
|
4
|
+
module TestObjectVerification
|
5
|
+
|
6
|
+
# private variables and methods
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# TODO: Document me (TestObjectFactory::check_verify_always_reporting_settings)
|
10
|
+
def check_verify_always_reporting_settings
|
11
|
+
|
12
|
+
@@reporter_attached = MobyUtil::Parameter[ :report_attach_continuous_verification_to_reporter, 'false' ]
|
13
|
+
|
14
|
+
@@rcv_raise_errors = MobyUtil::Parameter[ :report_continuous_verification_raise_errors, 'true' ]
|
15
|
+
|
16
|
+
@@rcv_fail_test_case = MobyUtil::Parameter[ :report_continuous_verification_fail_test_case_on_error, 'true' ]
|
17
|
+
|
18
|
+
@@rvc_capture_screen = MobyUtil::Parameter[ :report_continuous_verification_capture_screen_on_error, 'true' ]
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO: Document me (TestObjectFactory::restore_verify_always_reporting_settings)
|
23
|
+
def restore_global_verify_always_reporting_settings
|
24
|
+
|
25
|
+
@@reporter_attached = @@global_reporter_attached
|
26
|
+
|
27
|
+
@@rcv_raise_errors = @@rcv_global_raise_errors
|
28
|
+
|
29
|
+
@@rcv_fail_test_case = @@rcv_global_fail_test_case
|
30
|
+
|
31
|
+
@@rvc_capture_screen = @@rvc_global_capture_screen
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize_settings
|
36
|
+
|
37
|
+
# defaults
|
38
|
+
@@global_reporter_attached = MobyUtil::Parameter[ :report_attach_continuous_verification_to_reporter, 'false' ]
|
39
|
+
|
40
|
+
@@rcv_global_raise_errors = MobyUtil::Parameter[ :report_continuous_verification_raise_errors, 'true' ]
|
41
|
+
|
42
|
+
@@rcv_global_fail_test_case = MobyUtil::Parameter[ :report_continuous_verification_fail_test_case_on_error, 'true' ]
|
43
|
+
|
44
|
+
@@rvc_global_capture_screen = MobyUtil::Parameter[ :report_continuous_verification_capture_screen_on_error, 'true' ]
|
45
|
+
|
46
|
+
@@inside_verify = false
|
47
|
+
|
48
|
+
@@initialized = true
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# defaults
|
53
|
+
@@initialized = false
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.verify_ui_dump( sut )
|
58
|
+
|
59
|
+
initialize_settings unless @@initialized
|
60
|
+
|
61
|
+
return if @@inside_verify
|
62
|
+
|
63
|
+
begin
|
64
|
+
|
65
|
+
@@inside_verify = true
|
66
|
+
|
67
|
+
logging_enabled = MobyUtil::Logger.instance.enabled
|
68
|
+
|
69
|
+
sut.verify_blocks.each do | verify |
|
70
|
+
|
71
|
+
check_verify_always_reporting_settings()
|
72
|
+
|
73
|
+
begin
|
74
|
+
|
75
|
+
MobyUtil::Logger.instance.enabled = false
|
76
|
+
|
77
|
+
begin
|
78
|
+
|
79
|
+
result = verify.block.call( sut )
|
80
|
+
|
81
|
+
rescue Exception => e
|
82
|
+
|
83
|
+
if @@rcv_raise_errors == 'true' || @@reporter_attached == 'false'
|
84
|
+
|
85
|
+
raise MobyBase::ContinuousVerificationError.new(
|
86
|
+
"Verification failed as an exception was thrown when the verification block was executed. %s\nDetails: %s\nNested exception:\n%s" % [ verify.source, ( verify.message || "none" ), e.inspect ]
|
87
|
+
)
|
88
|
+
elsif @@reporter_attached == 'true' && @@rcv_raise_errors == 'false'
|
89
|
+
|
90
|
+
TDriverReportAPI::tdriver_report_set_test_case_status('failed') if @@rcv_fail_test_case == 'true'
|
91
|
+
|
92
|
+
if @@rvc_capture_screen == 'true'
|
93
|
+
|
94
|
+
TDriverReportAPI::tdriver_capture_state
|
95
|
+
|
96
|
+
else
|
97
|
+
|
98
|
+
TDriverReportAPI::tdriver_capture_state( false )
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
TDriverReportAPI::tdriver_report_log("Verification failed as an exception was thrown when the verification block was executed. %s\nDetails: %s\nNested exception:\n%s" % [ verify.source, ( verify.message || "none" ), e.inspect ])
|
103
|
+
|
104
|
+
TDriverReportAPI::tdriver_report_log("<hr />")
|
105
|
+
|
106
|
+
MobyUtil::Logger.instance.enabled = logging_enabled
|
107
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
unless result == verify.expected
|
114
|
+
|
115
|
+
if @@rcv_raise_errors == 'true' || @@reporter_attached == 'false'
|
116
|
+
|
117
|
+
raise MobyBase::ContinuousVerificationError.new(
|
118
|
+
"Verification failed. %s\nDetails: %s\nThe block did not return %s. It returned: %s" % [
|
119
|
+
verify.source, ( verify.message || "none" ), verify.expected.inspect, result.inspect
|
120
|
+
]
|
121
|
+
)
|
122
|
+
|
123
|
+
elsif @@reporter_attached == 'true' && @@rcv_raise_errors == 'false'
|
124
|
+
|
125
|
+
TDriverReportAPI::tdriver_report_set_test_case_status('failed') if @@rcv_fail_test_case == 'true'
|
126
|
+
|
127
|
+
if @@rvc_capture_screen == 'true'
|
128
|
+
|
129
|
+
TDriverReportAPI::tdriver_capture_state
|
130
|
+
|
131
|
+
else
|
132
|
+
|
133
|
+
TDriverReportAPI::tdriver_capture_state( false )
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
TDriverReportAPI::tdriver_report_log(
|
138
|
+
"Verification failed. %s\nDetails: %s\nThe block did not return %s. It returned: %s " % [
|
139
|
+
verify.source, ( verify.message || "none" ), verify.expected.inspect, result.inspect
|
140
|
+
]
|
141
|
+
)
|
142
|
+
|
143
|
+
TDriverReportAPI::tdriver_report_log("<hr />")
|
144
|
+
|
145
|
+
MobyUtil::Logger.instance.enabled = logging_enabled
|
146
|
+
|
147
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
rescue Exception => e
|
154
|
+
|
155
|
+
MobyUtil::Logger.instance.enabled = logging_enabled
|
156
|
+
|
157
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
|
158
|
+
|
159
|
+
@@inside_verify = false
|
160
|
+
|
161
|
+
Kernel::raise e
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
# Do NOT report PASS cases, like other verify blocks do. This would clog the log with useless info.
|
166
|
+
restore_global_verify_always_reporting_settings
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
ensure
|
171
|
+
|
172
|
+
MobyUtil::Logger.instance.enabled = logging_enabled
|
173
|
+
@@inside_verify = false
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end # verify_ui
|
178
|
+
|
179
|
+
end # TestObjectVerification
|
180
|
+
|
181
|
+
end # TDriver
|