Module: MobyBehaviour::QT::Fixture

Includes:
Behaviour
Defined in:
lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb

Overview

description

Fixture specific behaviours

behaviour

QtFixture

requires

testability-driver-qt-sut-plugin

input_type

*

sut_type

qt

sut_version

*

objects

sut;*

Instance Method Summary collapse

Methods included from Behaviour

#command_params

Instance Method Details

#async_fixture(fixture_name, fixture_method, parameters_hash = {}) ⇒ Object

description

Sends a fixture call to the target. The fixture will be executed either inside the application process or the qttasserver process (if used for sut). The fixture will get a pointer to the object to which this call is made to. This version of the fixture call is asynchronous. This means that no return value is returned.

arguments

fixture_name

String
 description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file
 example: tasfixture

fixture_method

String
 description: Name of the action to be executed in the fixture
 example: callApi

parameters_hash

Hash
 description: Optional hash of parameters passed on to the fixture
 example: {:name => 'John'}

returns

NilClass

description: -
example: -

exceptions

ArgumentError

description:  In case the given parameters are not valid.


156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb', line 156

def async_fixture( fixture_name, fixture_method, parameters_hash = {} )

   # verify that arguments were given in correct format
   fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'

   fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'

   parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'

 result = nil

   begin

     # default parameters
     params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true }

     # for sut send the fixture command to qttasserver (appid nil)
     if sut?

       params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )

     else

       params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )

     end

     result = @sut.execute_command( MobyCommand::Fixture.new( params ) )

   rescue

     $logger.behaviour "FAIL;Failed when calling async_fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"

     raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }")

   end

   $logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"

   result

end

#fixture(fixture_name, fixture_method, parameters_hash = {}) ⇒ Object

description

Sends a fixture call to the target. The fixture will be executed either inside the application process or the qttasserver process (if used for sut). The fixture will get a pointer to the object to which this call is made to.

arguments

fixture_name

String
 description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file.
 example: tasfixture

fixture_method

String
 description: Name of the action to be executed in the fixture.
 example: callApi

parameters_hash

Hash
 description: Optional hash of pareters passed on to the fixture.
 example: {:name => 'John'}

returns

QString

description: The value returned but the fixture.
example: OK

exceptions

ArgumentError

description:  In case the given parameters are not valid.


80
81
82
83
84
85
86
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
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb', line 80

def fixture( fixture_name, fixture_method, parameters_hash = {} )

   # verify that arguments were given in correct format
   fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'

   fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'

   parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'

 result = nil

 begin

     # default parameters
   params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false }

    # for sut send the fixture command to qttasserver (appid nil)
     if sut?

    params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )

     else

    params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )

     end

     result = @sut.execute_command( MobyCommand::Fixture.new( params ) )
   
 rescue

   $logger.behaviour "FAIL;Failed when calling fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"

   raise MobyBase::BehaviourError.new( "Fixture", "Failed to execute fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }" )

 end

 $logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"

 result

end

#fixturesObject

nodoc



200
201
202
203
204
205
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb', line 200

def fixtures

  # pass call to fixtures service object          
  TDriver::FixtureService.new( :target => self )

end