auto_test 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/authentication.rb +0 -1
- data/lib/auto_test/version.rb +1 -1
- data/lib/auto_test.rb +12 -3
- data/lib/dsl.rb +0 -3
- data/lib/error.rb +0 -1
- data/lib/page.rb +0 -3
- data/lib/spec/requests/auto_spec.rb +3 -4
- data/lib/test.rb +0 -65
- data/lib/test_starter.rb +58 -0
- metadata +3 -2
data/lib/authentication.rb
CHANGED
data/lib/auto_test/version.rb
CHANGED
data/lib/auto_test.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
require "auto_test/version"
|
2
|
+
require 'page'
|
3
|
+
require 'test'
|
4
|
+
require 'error'
|
5
|
+
require 'authentication'
|
6
|
+
require 'dsl'
|
2
7
|
|
3
8
|
def logger
|
4
9
|
Rails.logger
|
@@ -6,6 +11,12 @@ end
|
|
6
11
|
|
7
12
|
|
8
13
|
module AutoTest
|
14
|
+
include Page
|
15
|
+
include Error
|
16
|
+
include Authentication
|
17
|
+
include Dsl
|
18
|
+
include Test
|
19
|
+
|
9
20
|
require "auto_test/railtie" if defined?(Rails)
|
10
21
|
|
11
22
|
class << self
|
@@ -107,8 +118,6 @@ module AutoTest
|
|
107
118
|
|
108
119
|
end
|
109
120
|
|
110
|
-
autoload :Dsl, 'dsl'
|
111
|
-
autoload :Test, 'test'
|
112
|
-
|
121
|
+
autoload :Dsl, 'dsl'
|
113
122
|
|
114
123
|
end
|
data/lib/dsl.rb
CHANGED
data/lib/error.rb
CHANGED
data/lib/page.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# run without cleaning the db between single tests
|
5
5
|
# see spec_helper for db-cleaner
|
6
6
|
require 'spec_helper'
|
7
|
-
|
8
|
-
|
7
|
+
require 'auto_test'
|
8
|
+
require 'test_starter'
|
9
9
|
|
10
10
|
describe "Application" do
|
11
11
|
|
@@ -15,8 +15,7 @@ describe "Application" do
|
|
15
15
|
end
|
16
16
|
it "does test the application automatically" do
|
17
17
|
load "#{Rails.root}/db/test_seeds.rb"
|
18
|
-
|
19
|
-
t = AutoTest::TestStarter.new
|
18
|
+
t = TestStarter.new
|
20
19
|
t.test
|
21
20
|
end
|
22
21
|
end
|
data/lib/test.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'capybara/rspec'
|
2
|
-
#require 'watir-webdriver'
|
3
1
|
module AutoTest
|
4
2
|
module Test
|
5
3
|
module_function
|
6
|
-
|
7
|
-
|
8
4
|
# initialize all variables
|
9
5
|
def initialize_test
|
10
6
|
Error.init_error
|
@@ -310,9 +306,6 @@ module AutoTest
|
|
310
306
|
@@no_session_links
|
311
307
|
end
|
312
308
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
309
|
def write_user_input_to_file
|
317
310
|
f = File.new("#{Rails.root}/log/user_input.log", "w")
|
318
311
|
if Test.no_auth then
|
@@ -335,64 +328,6 @@ module AutoTest
|
|
335
328
|
|
336
329
|
end
|
337
330
|
|
338
|
-
class TestStarter
|
339
|
-
# method to start the test and handle errors
|
340
|
-
def test
|
341
|
-
Test.write_user_input_to_file
|
342
|
-
for j in 1..Test.get_number_of_test_runs do
|
343
|
-
Test.run = j
|
344
|
-
if !Test.stop?
|
345
|
-
number_of_sessions = Test.get_number_of_sessions
|
346
|
-
Test.init_sessions_array
|
347
|
-
Test.init_sessions
|
348
|
-
Test.init_ready
|
349
|
-
for i in 0..number_of_sessions-1 do
|
350
|
-
sess = Capybara::Session.new(:rack_test,Rails.application)
|
351
|
-
Test.add_to_sessions_array sess
|
352
|
-
Test.init_hash_sessions(i, Hash.new)
|
353
|
-
Test.sessions(i,"depth", 0)
|
354
|
-
Test.sessions(i,"iterations", 0)
|
355
|
-
if !Test.no_auth then
|
356
|
-
user = Authentication.get_users[rand(Authentication.get_users.size)]
|
357
|
-
Test.sessions(i,"user", user)
|
358
|
-
Test.add_to_action_path "#{i}:#{user.id}ID"
|
359
|
-
Test.sessions(i,"current_user", 0)
|
360
|
-
end
|
361
|
-
Test.sessions(i,"ready", false)
|
362
|
-
Test.sessions(i,"iteration", 0)
|
363
|
-
Test.sessions(i,"current_depth", 0)
|
364
|
-
Test.sessions(i,"paths", Hash.new)
|
365
|
-
end
|
366
|
-
Error.init_error
|
367
|
-
puts
|
368
|
-
Test.link_counter = 0
|
369
|
-
Test.users_logged_in = 1
|
370
|
-
if Test.no_auth then
|
371
|
-
Test.users_logged_in = 0
|
372
|
-
end
|
373
|
-
STDOUT.write("\r#{Test.run}. run: \t#{Test.link_counter} links clicked, \t#{Test.users_logged_in} users logged in, \t#{Error.get_error} Errors")
|
374
|
-
while !Test.stop? && !Test.ready? do
|
375
|
-
session = rand(number_of_sessions)
|
376
|
-
for i in 0..rand(Test.get_max_number_of_session_links) do
|
377
|
-
Page.run_session(session)
|
378
|
-
end
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|
382
|
-
Test.check_invariants
|
383
|
-
if !Test.stop? then Test.users_logged_in = Test.users_logged_in + 1 end
|
384
|
-
f = File.new("#{Rails.root}/log/paths.log", "w")
|
385
|
-
f.puts(Test.action_path)
|
386
|
-
f.close
|
387
|
-
puts
|
388
|
-
Error.print_errors
|
389
|
-
f = File.new("#{Rails.root}/log/errors.log", "w")
|
390
|
-
f.puts(Error.get_error)
|
391
|
-
f.puts(Error.get_error_messages)
|
392
|
-
f.close
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
331
|
autoload :Authentication, 'authentication'
|
397
332
|
autoload :Error, 'error'
|
398
333
|
|
data/lib/test_starter.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class TestStarter
|
2
|
+
include AutoTest
|
3
|
+
# method to start the test and handle errors
|
4
|
+
def test
|
5
|
+
Test.write_user_input_to_file
|
6
|
+
for j in 1..Test.get_number_of_test_runs do
|
7
|
+
Test.run = j
|
8
|
+
if !Test.stop?
|
9
|
+
number_of_sessions = Test.get_number_of_sessions
|
10
|
+
Test.init_sessions_array
|
11
|
+
Test.init_sessions
|
12
|
+
Test.init_ready
|
13
|
+
for i in 0..number_of_sessions-1 do
|
14
|
+
sess = Capybara::Session.new(:rack_test,Rails.application)
|
15
|
+
Test.add_to_sessions_array sess
|
16
|
+
Test.init_hash_sessions(i, Hash.new)
|
17
|
+
Test.sessions(i,"depth", 0)
|
18
|
+
Test.sessions(i,"iterations", 0)
|
19
|
+
if !Test.no_auth then
|
20
|
+
user = Authentication.get_users[rand(Authentication.get_users.size)]
|
21
|
+
Test.sessions(i,"user", user)
|
22
|
+
Test.add_to_action_path "#{i}:#{user.id}ID"
|
23
|
+
Test.sessions(i,"current_user", 0)
|
24
|
+
end
|
25
|
+
Test.sessions(i,"ready", false)
|
26
|
+
Test.sessions(i,"iteration", 0)
|
27
|
+
Test.sessions(i,"current_depth", 0)
|
28
|
+
Test.sessions(i,"paths", Hash.new)
|
29
|
+
end
|
30
|
+
Error.init_error
|
31
|
+
puts
|
32
|
+
Test.link_counter = 0
|
33
|
+
Test.users_logged_in = 1
|
34
|
+
if Test.no_auth then
|
35
|
+
Test.users_logged_in = 0
|
36
|
+
end
|
37
|
+
STDOUT.write("\r#{Test.run}. run: \t#{Test.link_counter} links clicked, \t#{Test.users_logged_in} users logged in, \t#{Error.get_error} Errors")
|
38
|
+
while !Test.stop? && !Test.ready? do
|
39
|
+
session = rand(number_of_sessions)
|
40
|
+
for i in 0..rand(Test.get_max_number_of_session_links) do
|
41
|
+
Page.run_session(session)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Test.check_invariants
|
47
|
+
if !Test.stop? then Test.users_logged_in = Test.users_logged_in + 1 end
|
48
|
+
f = File.new("#{Rails.root}/log/paths.log", "w")
|
49
|
+
f.puts(Test.action_path)
|
50
|
+
f.close
|
51
|
+
puts
|
52
|
+
Error.print_errors
|
53
|
+
f = File.new("#{Rails.root}/log/errors.log", "w")
|
54
|
+
f.puts(Error.get_error)
|
55
|
+
f.puts(Error.get_error_messages)
|
56
|
+
f.close
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: auto_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Maike Hargens
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faker
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/spec/requests/simulation_spec.rb
|
108
108
|
- lib/tasks/auto_test.rb
|
109
109
|
- lib/test.rb
|
110
|
+
- lib/test_starter.rb
|
110
111
|
homepage:
|
111
112
|
licenses: []
|
112
113
|
|