Module: AutoTest::Test

Defined in:
lib/test.rb

Class Method Summary collapse

Class Method Details

.action_pathObject



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

def action_path
  @@action_paths
end

.add_to_action_path(hash) ⇒ Object



225
226
227
# File 'lib/test.rb', line 225

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

.add_to_sessions_array(session) ⇒ Object



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

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



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

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

.check_invariantsObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/test.rb', line 63

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



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

def get_always_present
  @@always_present
end

.get_depthObject



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

def get_depth
  @@depth
end

.get_inputsObject



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

def get_inputs
  @@inputs
end


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

def get_links_to_exclude
  @@links
end

.get_max_depthObject



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

def get_max_depth
  @@max_depth
end


291
292
293
# File 'lib/test.rb', line 291

def get_max_number_of_session_links
  @@no_session_links
end

.get_number_of_sessionsObject



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

def get_number_of_sessions
  @@number_of_sessions
end

.get_number_of_test_runsObject



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

def get_number_of_test_runs
  @@runs 
end

.get_object_dependenciesObject

get object dependencies



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

def get_object_dependencies
  @@dependencies 
end

.get_sessions(i, key) ⇒ Object



267
268
269
# File 'lib/test.rb', line 267

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

.get_sessions_arrayObject



271
272
273
# File 'lib/test.rb', line 271

def get_sessions_array
  @sessions_array
end

.inc_depthObject

incremtent the depth



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

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

.init_action_pathObject



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

def init_action_path
 @@action_paths = []
end

.init_always_presentObject



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

def init_always_present
 @@always_present = []
end

.init_authObject



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

def init_auth 
  @@no_auth = false
end

.init_depthObject

initialize the depth of link search with 0



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

def init_depth
 @@depth = 0
end

.init_hash_sessions(key, value) ⇒ Object



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

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

.init_inputsObject



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

def init_inputs
 @@inputs = Hash.new
end

.init_number_of_test_runsObject



24
25
26
# File 'lib/test.rb', line 24

def init_number_of_test_runs
  @@runs = 1
end

.init_object_dependenciesObject

initialize dependency array



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

def init_object_dependencies
 @@dependencies = []
end

.init_readyObject



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

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

.init_sessionsObject



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

def init_sessions
  @sessions = Hash.new
end

.init_sessions_arrayObject



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

def init_sessions_array 
  @sessions_array = []
end

.init_stopObject



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

def init_stop
  @@stop = false
end

.init_stop_at_first_errorObject



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

def init_stop_at_first_error
  @@stop_at_first_error = false
end

.initialize_testObject

initialize all variables



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

def initialize_test
  Error.init_error

  Authentication.init_users
  Authentication.
  init_action_path
  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



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

def iterations
  @iterations
end

.iterations=(value) ⇒ Object



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

def iterations=(value)
  @iterations = value
end


198
199
200
# File 'lib/test.rb', line 198

def link_counter
  @link_counter 
end


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

def link_counter=(value)
  @link_counter = value
end

list of links that will not be clicked during the test



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

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

.no_authObject



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

def no_auth
  @@no_auth
end

.pathsObject



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

def paths
  @paths
end

.paths=(value) ⇒ Object



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

def paths=(value)
  @paths = value
end

.ready(i) ⇒ Object



237
238
239
# File 'lib/test.rb', line 237

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

.ready?Boolean

Returns:

  • (Boolean)


241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/test.rb', line 241

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



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

def run
  @run
end

.run=(value) ⇒ Object



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

def run=(value)
  @run = value
end

.sessions(index, key, value) ⇒ Object



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

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



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

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

.set_max_depth(value) ⇒ Object



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

def set_max_depth(value)
  @@max_depth = value
end


287
288
289
# File 'lib/test.rb', line 287

def set_max_number_of_session_links(no)
  @@no_session_links = no
end

.set_no_authObject



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

def set_no_auth
  @@no_auth = true
end

.set_number_of_sessions(number) ⇒ Object



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

def set_number_of_sessions(number)
  @@number_of_sessions = number
end

.set_number_of_test_runs(number) ⇒ Object



93
94
95
# File 'lib/test.rb', line 93

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



142
143
144
# File 'lib/test.rb', line 142

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

.stop!Object



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

def stop!
  @@stop = true
end

.stop?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/test.rb', line 109

def stop?
  @@stop
end

.stop_at_first_error(stop_at_first_error) ⇒ Object



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

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)


105
106
107
# File 'lib/test.rb', line 105

def stop_at_first_error?
  @@stop_at_first_error
end

.users_logged_inObject



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

def users_logged_in
  @users_logged_in
end

.users_logged_in=(value) ⇒ Object



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

def users_logged_in=(value)
  @users_logged_in = value
end

.write_user_input_to_fileObject



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/test.rb', line 296

def write_user_input_to_file
  f = File.new("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_logout_path:#{Authentication.get_logout_path}
    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