Module: MobyBehaviour::TestObjectSynchronization
- Includes:
- Behaviour
- Defined in:
- lib/tdriver/base/test_object/behaviours/syncronization.rb
Overview
description
TDriver synchronization functionality. These methods make it possible to wait until the SUT is in some user defined state
behaviour
GenericTestObjectSynchronization
requires
input_type
sut_type
sut_version
objects
*;sut
Instance Method Summary collapse
-
#wait_child(attributes = {}, timeout = 10, retry_interval = 0.5) ⇒ Object
Wait until this test object has a child test object matching the given attributes or timeout exceeds.
Instance Method Details
#wait_child(attributes = {}, timeout = 10, retry_interval = 0.5) ⇒ Object
Wait until this test object has a child test object matching the given attributes or timeout exceeds. An exception will be raised if test object was not found in the specified timeout.
arguments
attributes Hash description: Hash defining the set of attributes that the child test object must possess. example: :text=>'1'
timeout Fixnum description: Overriding the default synchronization timeout example: 30
retry_interval Fixnum description: Time used before retrying to find test object example: 1
returns
MobyBase::TestObject description: Returns receiver object of this method, not the found object example: -
exceptions
TypeError
description: Wrong argument type
TypeError
description: Wrong argument type
TypeError
description: Wrong argument type
ArgumentError description: Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float
MobyBase::SyncTimeoutError description: Synchronization timed out (%i) before the defined child object could be found
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/tdriver/base/test_object/behaviours/syncronization.rb', line 87 def wait_child( attributes = {}, timeout = 10, retry_interval = 0.5 ) # verify that attributes is type of Hash attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" ) # verify that :type is type of String attributes[ :type ].check_type( String, "Wrong argument type $1 for attribute :type (expected $2)" ) # verify that :type is not empty string attributes[ :type ].not_empty( "Attribute :type must not be empty" ) # verify timeout type is numeric timeout.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for timeout (expected $2)" ) # verify timeout type is numeric retry_interval.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for retry interval (expected $2)" ) begin dynamic_attributes = attributes.strip_dynamic_attributes! # try to identify desired child test object @test_object_factory.identify_object( :object_attributes_hash => attributes, :identification_directives => dynamic_attributes.default_values( :__timeout => timeout, :__retry_interval => retry_interval, :__refresh_arguments => kind_of?( MobyBase::SUT ) ? attributes : { :id => get_application_id }, :__parent_application => sut? == true ? nil : @parent_application ), :parent => self ) rescue MobyBase::TestObjectNotFoundError # the child object was not found in the specified timeout raise MobyBase::SyncTimeoutError, "Synchronization timed out (#{ timeout }) before the defined child object could be found." rescue MobyBase::ApplicationNotAvailableError raise rescue # unexpected errors raise RuntimeError, "Synchronization failed due to #{ $!.message } (#{ $!.class })" end self end |