Module: AutoTest::Test

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

Class Method Summary collapse

Class Method Details

.action_pathObject



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

def action_path
  @@action_paths
end

.add_to_action_path(hash) ⇒ Object



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

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

.add_to_sessions_array(session) ⇒ Object



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

def add_to_sessions_array(session)
  @sessions_array << session
end

.always_present(class_name, key, value) ⇒ Object

add an array of the classname, key and value of the object to be checked every cycle



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

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

.check_invariantsObject



77
78
79
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
# File 'lib/test.rb', line 77

def check_invariants
  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
  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

.get_always_presentObject



183
184
185
# File 'lib/test.rb', line 183

def get_always_present
  @@always_present
end

.get_depthObject



136
137
138
# File 'lib/test.rb', line 136

def get_depth
  @@depth
end

.get_inputsObject



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

def get_inputs
  @@inputs
end


187
188
189
# File 'lib/test.rb', line 187

def get_links_to_exclude
  @@links
end

.get_max_depthObject



144
145
146
# File 'lib/test.rb', line 144

def get_max_depth
  @@max_depth
end


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

def get_max_number_of_session_links
  @@no_session_links
end

.get_number_of_sessionsObject



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

def get_number_of_sessions
  @@number_of_sessions
end

.get_number_of_test_runsObject



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

def get_number_of_test_runs
  @@runs 
end

.get_object_dependenciesObject

get object dependencies



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

def get_object_dependencies
  @@dependencies 
end

.get_sessions(i, key) ⇒ Object



281
282
283
# File 'lib/test.rb', line 281

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

.get_sessions_arrayObject



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

def get_sessions_array
  @sessions_array
end

.inc_depthObject

incremtent the depth



132
133
134
# File 'lib/test.rb', line 132

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

.init_action_pathObject



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

def init_action_path
 @@action_paths = []
end

.init_always_presentObject



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

def init_always_present
 @@always_present = []
end

.init_authObject



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

def init_auth 
  @@no_auth = false
end

.init_depthObject

initialize the depth of link search with 0



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

def init_depth
 @@depth = 0
end

.init_fixturesObject



22
23
24
# File 'lib/test.rb', line 22

def init_fixtures
  @@use_fixtures = false
end

.init_hash_sessions(key, value) ⇒ Object



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

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

.init_inputsObject



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

def init_inputs
 @@inputs = Hash.new
end


38
39
40
# File 'lib/test.rb', line 38

def init_links  
  @@links = []
end

.init_number_of_test_runsObject



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

def init_number_of_test_runs
  @@runs = 1
end

.init_object_dependenciesObject

initialize dependency array



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

def init_object_dependencies
 @@dependencies = []
end

.init_readyObject



247
248
249
# File 'lib/test.rb', line 247

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

.init_sessionsObject



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

def init_sessions
  @sessions = Hash.new
end

.init_sessions_arrayObject



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

def init_sessions_array 
  @sessions_array = []
end

.init_stopObject



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

def init_stop
  @@stop = false
end

.init_stop_at_first_errorObject



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

def init_stop_at_first_error
  @@stop_at_first_error = false
end

.initialize_testObject

initialize all variables



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

def initialize_test
  Error.init_error
  Authentication.init_users
  Authentication.
  init_fixtures
  init_action_path
  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



204
205
206
# File 'lib/test.rb', line 204

def iterations
  @iterations
end

.iterations=(value) ⇒ Object



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

def iterations=(value)
  @iterations = value
end


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

def link_counter
  @link_counter 
end


215
216
217
# File 'lib/test.rb', line 215

def link_counter=(value)
  @link_counter = value
end

list of links that will not be clicked during the test



192
193
194
# File 'lib/test.rb', line 192

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

.no_authObject



231
232
233
# File 'lib/test.rb', line 231

def no_auth
  @@no_auth
end

.pathsObject



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

def paths
  @paths
end

.paths=(value) ⇒ Object



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

def paths=(value)
  @paths = value
end

.ready(i) ⇒ Object



251
252
253
# File 'lib/test.rb', line 251

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

.ready?Boolean

Returns:

  • (Boolean)


255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/test.rb', line 255

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



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

def run
  @run
end

.run=(value) ⇒ Object



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

def run=(value)
  @run = value
end

.sessions(index, key, value) ⇒ Object



277
278
279
# File 'lib/test.rb', line 277

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



162
163
164
# File 'lib/test.rb', line 162

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

.set_max_depth(value) ⇒ Object



140
141
142
# File 'lib/test.rb', line 140

def set_max_depth(value)
  @@max_depth = value
end


301
302
303
# File 'lib/test.rb', line 301

def set_max_number_of_session_links(no)
  @@no_session_links = no
end

.set_no_authObject



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

def set_no_auth
  @@no_auth = true
end

.set_number_of_sessions(number) ⇒ Object



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

def set_number_of_sessions(number)
  @@number_of_sessions = number
end

.set_number_of_test_runs(number) ⇒ Object



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

def set_number_of_test_runs(number)
  @@runs = number
end

.set_object_dependency(child, parent, attribute_name) ⇒ Object

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



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

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

.stop!Object



127
128
129
# File 'lib/test.rb', line 127

def stop!
  @@stop = true
end

.stop?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/test.rb', line 123

def stop?
  @@stop
end

.stop_at_first_error(stop_at_first_error) ⇒ Object



115
116
117
# File 'lib/test.rb', line 115

def stop_at_first_error(stop_at_first_error) 
  @@stop_at_first_error = stop_at_first_error
end

.stop_at_first_error?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/test.rb', line 119

def stop_at_first_error?
  @@stop_at_first_error
end

.use_fixtures(bool) ⇒ Object



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

def use_fixtures(bool)
  @@use_fixtures = bool
end

.use_fixtures?Boolean

Returns:

  • (Boolean)


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

def use_fixtures?
  @@use_fixtures
end

.users_logged_inObject



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

def users_logged_in
  @users_logged_in
end

.users_logged_in=(value) ⇒ Object



297
298
299
# File 'lib/test.rb', line 297

def users_logged_in=(value)
  @users_logged_in = value
end

.write_user_input_to_fileObject



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/test.rb', line 309

def write_user_input_to_file
  f = File.new("#{Rails.root}/log/user_input.log", "w")
  if Test.no_auth then
    f.puts("get_number_of_test_runs:#{get_number_of_test_runs}
    get_number_of_sessions:#{get_number_of_sessions}")
  else
    f.puts("get_number_of_test_runs:#{get_number_of_test_runs}
    get_login_path:#{Authentication.get_login_path}
    get_logout_path:#{Authentication.get_logout_path}
    get_login_attributes:#{Authentication.get_login_attributes}
    get_number_of_sessions:#{get_number_of_sessions}
    get_login_data:#{Authentication.get_login_data}
    get_login_names:#{Authentication.get_login_names}
    get_unique_login_attribute_name:#{Authentication.get_unique_login_attribute_name}
    use_db_users:#{Authentication.use_db_users}
    user_class:#{Authentication.user_class}")
  end
  f.close
end