Module: AutoTest::Test

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

Class Method Summary collapse

Class Method Details

.action_pathObject



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

def action_path
  @@action_paths
end

.add_to_action_path(hash) ⇒ Object



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

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

.add_to_sessions_array(session) ⇒ Object



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

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



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

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

.check_invariantsObject



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

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

.fixtures(*fixtures) ⇒ Object



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

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

.get_always_presentObject



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

def get_always_present
  @@always_present
end

.get_depthObject



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

def get_depth
  @@depth
end

.get_fixturesObject



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

def get_fixtures
  @@fixtures
end

.get_inputsObject



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

def get_inputs
  @@inputs
end


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

def get_links_to_exclude
  @@links
end

.get_max_depthObject



152
153
154
# File 'lib/test.rb', line 152

def get_max_depth
  @@max_depth
end


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

def get_max_number_of_session_links
  @@no_session_links
end

.get_number_of_sessionsObject



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

def get_number_of_sessions
  @@number_of_sessions
end

.get_number_of_test_runsObject



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

def get_number_of_test_runs
  @@runs 
end

.get_object_dependenciesObject

get object dependencies



158
159
160
# File 'lib/test.rb', line 158

def get_object_dependencies
  @@dependencies 
end

.get_sessions(i, key) ⇒ Object



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

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

.get_sessions_arrayObject



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

def get_sessions_array
  @sessions_array
end

.inc_depthObject

incremtent the depth



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

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

.init_action_pathObject



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

def init_action_path
 @@action_paths = []
end

.init_always_presentObject



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

def init_always_present
 @@always_present = []
end

.init_authObject



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

def init_auth 
  @@no_auth = false
end

.init_depthObject

initialize the depth of link search with 0



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

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



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

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

.init_inputsObject



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

def init_inputs
 @@inputs = Hash.new
end


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

def init_links  
  @@links = []
end

.init_number_of_test_runsObject



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

def init_number_of_test_runs
  @@runs = 1
end

.init_object_dependenciesObject

initialize dependency array



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

def init_object_dependencies
 @@dependencies = []
end

.init_readyObject



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

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

.init_sessionsObject



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

def init_sessions
  @sessions = Hash.new
end

.init_sessions_arrayObject



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

def init_sessions_array 
  @sessions_array = []
end

.init_stopObject



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

def init_stop
  @@stop = false
end

.init_stop_at_first_errorObject



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

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



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

def iterations
  @iterations
end

.iterations=(value) ⇒ Object



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

def iterations=(value)
  @iterations = value
end


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

def link_counter
  @link_counter 
end


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

def link_counter=(value)
  @link_counter = value
end

list of links that will not be clicked during the test



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

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

.no_authObject



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

def no_auth
  @@no_auth
end

.pathsObject



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

def paths
  @paths
end

.paths=(value) ⇒ Object



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

def paths=(value)
  @paths = value
end

.ready(i) ⇒ Object



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

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

.ready?Boolean

Returns:

  • (Boolean)


263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/test.rb', line 263

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



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

def run
  @run
end

.run=(value) ⇒ Object



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

def run=(value)
  @run = value
end

.sessions(index, key, value) ⇒ Object



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

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



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

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

.set_max_depth(value) ⇒ Object



148
149
150
# File 'lib/test.rb', line 148

def set_max_depth(value)
  @@max_depth = value
end


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

def set_max_number_of_session_links(no)
  @@no_session_links = no
end

.set_no_authObject



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

def set_no_auth
  @@no_auth = true
end

.set_number_of_sessions(number) ⇒ Object



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

def set_number_of_sessions(number)
  @@number_of_sessions = number
end

.set_number_of_test_runs(number) ⇒ Object



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

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



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

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

.stop!Object



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

def stop!
  @@stop = true
end

.stop?Boolean

Returns:

  • (Boolean)


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

def stop?
  @@stop
end

.stop_at_first_error(stop_at_first_error) ⇒ Object



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

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)


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

def stop_at_first_error?
  @@stop_at_first_error
end

.use_fixtures(bool) ⇒ Object



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

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



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

def users_logged_in
  @users_logged_in
end

.users_logged_in=(value) ⇒ Object



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

def users_logged_in=(value)
  @users_logged_in = value
end

.write_user_input_to_fileObject



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/test.rb', line 317

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}
    use_fixtures:#{use_fixtures}
    get_login_path:#{Authentication.}
    #{if use_fixtures? then 'get_fixtures'+get_fixtures end}
    get_logout_path:#{Authentication.get_logout_path}
    get_login_button:#{Authentication.}
    get_login_attributes:#{Authentication.}
    get_number_of_sessions:#{get_number_of_sessions}
    get_login_data:#{Authentication.}
    get_login_names:#{Authentication.}
    get_unique_login_attribute_name:#{Authentication.}
    use_db_users:#{Authentication.use_db_users}
    user_class:#{Authentication.user_class}")
  end
  f.close
end