Module: AutoTest::Test

Included in:
AutoTest
Defined in:
lib/test.rb

Class Method Summary collapse

Class Method Details

.action_pathObject

getter for action path



294
295
296
# File 'lib/test.rb', line 294

def action_path
  @@action_paths
end

.add_to_action_path(hash) ⇒ Object

method to add an element to the action path



309
310
311
# File 'lib/test.rb', line 309

def add_to_action_path(hash)
  @@action_paths << hash
end

.add_to_sessions_array(session) ⇒ Object

method to add a session



355
356
357
# File 'lib/test.rb', line 355

def add_to_sessions_array(session)
  @sessions_array << session
end

.always_present(class_name, key, value) ⇒ Object

user function to set the invariant ‘always present’ add an array of the classname, key and value of the object to be checked every cycle



234
235
236
# File 'lib/test.rb', line 234

def always_present(class_name, key, value)
  @@always_present << [class_name, key, value]
end

.check_invariantsObject

check the invariants



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/test.rb', line 117

def check_invariants
  # check always present invariant
  get_always_present.each do |present|
    if present[0].find(:first, :conditions => "#{present[1]} = '#{present[2]}'") == nil then
      if stop_at_first_error? then stop! end
      logger.info "*"*100
      message = "ERROR  :   Invariant always_present : 
            class '#{present[0]}' attribute '#{present[1]}' value '#{present[2]}' was deleted"
      logger.error message
      logger.info "*"*100
      Error.inc_error(message)   
    end
  end
  # check object dependency invariant
  get_object_dependencies.each do |dependency|
    children = dependency[0].find(:all)
    children.each do |child|
      begin
        dependency[1].find(child.send(dependency[2].to_sym))
      rescue
        if stop_at_first_error? then stop! end
        logger.info "*"*100
        message = "ERROR  :   Invariant object_dependencies : 
              no '#{dependency[1]}' for #{dependency[0]} #{child.id}"
        logger.error message
        logger.info "*"*100
        Error.inc_error(message)   
      end
    end
  end
end

.fixtures(*fixtures) ⇒ Object

set the fixtures to be used



102
103
104
# File 'lib/test.rb', line 102

def fixtures(*fixtures)
  @@fixtures = fixtures
end

.get_always_presentObject

get invariant always present



239
240
241
# File 'lib/test.rb', line 239

def get_always_present
  @@always_present
end

.get_depthObject

get depth



185
186
187
# File 'lib/test.rb', line 185

def get_depth
  @@depth
end

.get_fixturesObject

get the fixtures



107
108
109
# File 'lib/test.rb', line 107

def get_fixtures
  @@fixtures
end

.get_inputsObject

get inputs



218
219
220
# File 'lib/test.rb', line 218

def get_inputs
  @@inputs
end

get the links to exclude from the test



244
245
246
# File 'lib/test.rb', line 244

def get_links_to_exclude
  @@links
end

.get_max_depthObject

get max depth



195
196
197
# File 'lib/test.rb', line 195

def get_max_depth
  @@max_depth
end

getter fo maximum number of session links



371
372
373
# File 'lib/test.rb', line 371

def get_max_number_of_session_links
  @@no_session_links
end

.get_number_of_sessionsObject

get number of sessions



228
229
230
# File 'lib/test.rb', line 228

def get_number_of_sessions
  @@number_of_sessions
end

.get_number_of_test_runsObject

get number of test runs



155
156
157
# File 'lib/test.rb', line 155

def get_number_of_test_runs
  @@runs 
end

.get_object_dependenciesObject

get object dependencies



200
201
202
# File 'lib/test.rb', line 200

def get_object_dependencies
  @@dependencies 
end

.get_sessions(i, key) ⇒ Object

get variables for a session



344
345
346
# File 'lib/test.rb', line 344

def get_sessions(i, key)
  @sessions["#{i}"]["#{key}"]
end

.get_sessions_arrayObject

getter for sessions array



349
350
351
# File 'lib/test.rb', line 349

def get_sessions_array
  @sessions_array
end

.inc_depthObject

incremtent the depth



180
181
182
# File 'lib/test.rb', line 180

def inc_depth
  @@depth = @@depth + 1
end

.init_action_pathObject



60
61
62
# File 'lib/test.rb', line 60

def init_action_path
 @@action_paths = []
end

.init_always_presentObject



69
70
71
# File 'lib/test.rb', line 69

def init_always_present
 @@always_present = []
end

.init_authObject



56
57
58
# File 'lib/test.rb', line 56

def init_auth 
  @@no_auth = false
end

.init_depthObject

initialize the depth of link search with 0



52
53
54
# File 'lib/test.rb', line 52

def init_depth
 @@depth = 0
end

.init_fixturesObject



31
32
33
# File 'lib/test.rb', line 31

def init_fixtures
  @@use_fixtures = false
end

.init_hash_sessions(key, value) ⇒ Object



81
82
83
# File 'lib/test.rb', line 81

def init_hash_sessions(key, value)
  @sessions["#{key}"] = value
end

.init_inputsObject



73
74
75
# File 'lib/test.rb', line 73

def init_inputs
 @@inputs = Hash.new
end

initializers



27
28
29
# File 'lib/test.rb', line 27

def init_links
  @@links = []
end

.init_number_of_test_runsObject



35
36
37
# File 'lib/test.rb', line 35

def init_number_of_test_runs
  @@runs = 1
end

.init_object_dependenciesObject

initialize dependency array



65
66
67
# File 'lib/test.rb', line 65

def init_object_dependencies
 @@dependencies = []
end

.init_readyObject



89
90
91
# File 'lib/test.rb', line 89

def init_ready
  @ready = Array.new(Test.get_number_of_sessions)
end

.init_sessionsObject



77
78
79
# File 'lib/test.rb', line 77

def init_sessions
  @sessions = Hash.new
end

.init_sessions_arrayObject



85
86
87
# File 'lib/test.rb', line 85

def init_sessions_array 
  @sessions_array = []
end

.init_stopObject



47
48
49
# File 'lib/test.rb', line 47

def init_stop
  @@stop = false
end

.init_stop_at_first_errorObject



43
44
45
# File 'lib/test.rb', line 43

def init_stop_at_first_error
  @@stop_at_first_error = false
end

.initialize_testObject

initialize all variables



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/test.rb', line 6

def initialize_test
  Error.init_error
  Authentication.init_users
  Authentication.
  init_fixtures
  init_action_path
  init_links
  init_links
  init_depth
  init_inputs
  init_always_present
  init_object_dependencies
  init_stop_at_first_error
  init_stop
  init_auth
  init_number_of_test_runs
end

.iterationsObject

getter for iterations



264
265
266
# File 'lib/test.rb', line 264

def iterations
  @iterations
end

.iterations=(value) ⇒ Object

setter for iterations



269
270
271
# File 'lib/test.rb', line 269

def iterations=(value)
  @iterations = value
end

getter for link counter



274
275
276
# File 'lib/test.rb', line 274

def link_counter
  @link_counter 
end

setter for link counter



279
280
281
# File 'lib/test.rb', line 279

def link_counter=(value)
  @link_counter = value
end

user function to set the list of links that will not be clicked during the test



249
250
251
# File 'lib/test.rb', line 249

def links_to_exclude(*links)
  @@links = links
end

.no_authObject

getter for no authentication



299
300
301
# File 'lib/test.rb', line 299

def no_auth
  @@no_auth
end

.pathsObject

getter for paths



259
260
261
# File 'lib/test.rb', line 259

def paths
  @paths
end

.paths=(value) ⇒ Object

setter for paths



254
255
256
# File 'lib/test.rb', line 254

def paths=(value)
  @paths = value
end

.ready(i) ⇒ Object

set one session to be finished in this round of the test



319
320
321
# File 'lib/test.rb', line 319

def ready(i)
  @ready[i-1] = true
end

.ready?Boolean

see if all sessions are ready

Returns:

  • (Boolean)


324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/test.rb', line 324

def ready?
  count = 0
  for i in 0..@ready.size-1 do
    if @ready[i] == true then
      count = count + 1
    end
  end
  if count == @ready.size then
    return true
  else 
    return false
  end
end

.runObject

getter for run



289
290
291
# File 'lib/test.rb', line 289

def run
  @run
end

.run=(value) ⇒ Object

setter for run



284
285
286
# File 'lib/test.rb', line 284

def run=(value)
  @run = value
end

.sessions(index, key, value) ⇒ Object

set variables for a session



339
340
341
# File 'lib/test.rb', line 339

def sessions(index, key, value)
  @sessions["#{index}"]["#{key}"] = value
end

.set_input(input, *values) ⇒ Object

for the name or part of the name of an input field, decide, which values to use if not set, random values matching the input type are used



213
214
215
# File 'lib/test.rb', line 213

def set_input(input, *values)
  @@inputs.store(input, values)
end

.set_max_depth(value) ⇒ Object

user function to set the maximum depth



190
191
192
# File 'lib/test.rb', line 190

def set_max_depth(value)
  @@max_depth = value
end

user function to set the maximum number of links a session may click before the next session continues



366
367
368
# File 'lib/test.rb', line 366

def set_max_number_of_session_links(no)
  @@no_session_links = no
end

.set_no_authObject

user function to determine that the application has no authentification



304
305
306
# File 'lib/test.rb', line 304

def set_no_auth
  @@no_auth = true
end

.set_number_of_sessions(number) ⇒ Object

user function to set the number of sessions used to test the app



223
224
225
# File 'lib/test.rb', line 223

def set_number_of_sessions(number)
  @@number_of_sessions = number
end

.set_number_of_test_runs(number) ⇒ Object

user function to set number of test runs



150
151
152
# File 'lib/test.rb', line 150

def set_number_of_test_runs(number)
  @@runs = number
end

.set_object_dependency(child, parent, attribute_name) ⇒ Object

user function to set invariant for object dependency for all objects of class child, there has to be one object of class parent attribute_name is the column that joins the two tables



207
208
209
# File 'lib/test.rb', line 207

def set_object_dependency(child, parent, attribute_name)
  @@dependencies << [child, parent, attribute_name]
end

.stop!Object

stop the test



175
176
177
# File 'lib/test.rb', line 175

def stop!
  @@stop = true
end

.stop?Boolean

has the test to be stopped?

Returns:

  • (Boolean)


170
171
172
# File 'lib/test.rb', line 170

def stop?
  @@stop
end

.stop_at_first_error(stop_at_first_error) ⇒ Object

user function ti stop at first error



160
161
162
# File 'lib/test.rb', line 160

def stop_at_first_error(stop_at_first_error) 
  @@stop_at_first_error = stop_at_first_error
end

.stop_at_first_error?Boolean

get stop at first error

Returns:

  • (Boolean)


165
166
167
# File 'lib/test.rb', line 165

def stop_at_first_error?
  @@stop_at_first_error
end

.use_fixtures(bool) ⇒ Object

determine if fixtures should be used



112
113
114
# File 'lib/test.rb', line 112

def use_fixtures(bool)
  @@use_fixtures = bool
end

.use_fixtures?Boolean

getter for use fixtures

Returns:

  • (Boolean)


97
98
99
# File 'lib/test.rb', line 97

def use_fixtures?
  @@use_fixtures
end

.users_logged_inObject

getter for number of users logged in during the test



314
315
316
# File 'lib/test.rb', line 314

def users_logged_in
  @users_logged_in
end

.users_logged_in=(value) ⇒ Object

setter for users logged in



360
361
362
# File 'lib/test.rb', line 360

def users_logged_in=(value)
  @users_logged_in = value
end