auto_test 0.1.9.7 → 0.1.9.8
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/auto_test/version.rb +1 -1
- data/lib/spec/requests/error_reduction_spec.rb +58 -52
- data/lib/spec/requests/simulation_spec.rb +9 -3
- data/lib/tasks/auto_test.rb +16 -17
- data/lib/test.rb +3 -0
- metadata +2 -2
data/lib/auto_test/version.rb
CHANGED
@@ -5,12 +5,15 @@ require 'auto_test'
|
|
5
5
|
|
6
6
|
|
7
7
|
describe "Application" do
|
8
|
-
|
9
8
|
describe "error path reduction" do
|
10
9
|
it "reduces the path to the error" do
|
10
|
+
init_user_inputs
|
11
11
|
load "#{Rails.root}/db/test_seeds.rb"
|
12
|
+
if user_inputs("use_fixtures") then
|
13
|
+
fixtures(*user_inputs("get_fixtures"))
|
14
|
+
end
|
12
15
|
init_path
|
13
|
-
|
16
|
+
|
14
17
|
init_sessions
|
15
18
|
init_sessions_array
|
16
19
|
number_of_sessions = user_inputs("get_number_of_sessions").to_i
|
@@ -41,7 +44,7 @@ describe "Application" do
|
|
41
44
|
rescue
|
42
45
|
end
|
43
46
|
session.visit user_inputs("get_login_path")
|
44
|
-
hash["#{get_sessions_array.index(session)}:#{session.current_path}"] =
|
47
|
+
hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = user_inputs("get_login_button")
|
45
48
|
if user_inputs("use_db_users") then
|
46
49
|
user_inputs("get_login_attributes").each do |field|
|
47
50
|
session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
|
@@ -59,7 +62,7 @@ describe "Application" do
|
|
59
62
|
session.fill_in field[1], :with => user_data[i]
|
60
63
|
end
|
61
64
|
end
|
62
|
-
session.
|
65
|
+
session.click_button user_inputs("get_login_button")
|
63
66
|
elsif a[1] == user_inputs("get_logout_path") then
|
64
67
|
hash["#{get_sessions_array.index(session)}:#{session.current_path}"] = user_inputs("get_logout_path")
|
65
68
|
session.visit user_inputs("get_logout_path")
|
@@ -105,60 +108,61 @@ describe "Application" do
|
|
105
108
|
end
|
106
109
|
rescue => e
|
107
110
|
if err_message == e.message.to_s.split(/:/,2).first then
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
111
|
+
add_path(hash)
|
112
|
+
new_path = jump_to_last_user(path)
|
113
|
+
init_enlarging_counter
|
114
|
+
error_not_found = true
|
115
|
+
# test the jump_to_last_user path
|
116
|
+
while error_not_found do
|
117
|
+
error_not_found = try_path(new_path)
|
118
|
+
if error_not_found then
|
119
|
+
new_path = enlarge_path(path)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
last_path = new_path
|
123
|
+
replace_same_users!(last_path)
|
124
|
+
user_count = user_count(last_path)
|
125
|
+
# test the path, getting divided
|
126
|
+
for i in 1..user_count do
|
127
|
+
error_not_found = false
|
128
|
+
index = nil
|
129
|
+
path_still_changing = true
|
130
|
+
last_index = nil
|
131
|
+
while !error_not_found && path_still_changing do
|
132
|
+
return_val = delete_links_half_way(last_path, index, i)
|
133
|
+
index = return_val[1]
|
134
|
+
if index == last_index then
|
135
|
+
path_still_changing = false
|
136
|
+
else
|
137
|
+
last_index = index
|
138
|
+
path_still_changing = true
|
139
|
+
end
|
140
|
+
next_path = return_val[0]
|
141
|
+
error_not_found = try_path(next_path)
|
142
|
+
while error_not_found do
|
129
143
|
return_val = delete_links_half_way(last_path, index, i)
|
130
144
|
index = return_val[1]
|
131
|
-
if index == last_index then
|
132
|
-
path_still_changing = false
|
133
|
-
else
|
134
|
-
last_index = index
|
135
|
-
path_still_changing = true
|
136
|
-
end
|
137
145
|
next_path = return_val[0]
|
138
146
|
error_not_found = try_path(next_path)
|
139
|
-
while error_not_found do
|
140
|
-
return_val = delete_links_half_way(last_path, index, i)
|
141
|
-
index = return_val[1]
|
142
|
-
next_path = return_val[0]
|
143
|
-
error_not_found = try_path(next_path)
|
144
|
-
end
|
145
|
-
if !error_not_found then
|
146
|
-
last_path = next_path
|
147
|
-
end
|
148
|
-
index = nil
|
149
147
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
148
|
+
if !error_not_found then
|
149
|
+
last_path = next_path
|
150
|
+
end
|
151
|
+
index = nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
last_path = delete_groups(last_path)
|
155
|
+
last_path = delete_single_links(last_path)
|
156
|
+
delete_ids(last_path)
|
157
|
+
f = File.new("#{Rails.root}/log/new_path.log", "w")
|
158
|
+
f.puts last_path
|
159
|
+
f.close
|
157
160
|
end
|
158
161
|
end
|
159
162
|
end
|
160
163
|
end
|
161
164
|
end
|
165
|
+
|
162
166
|
def delete_links_without_input(new_path, number_of_links, session)
|
163
167
|
next_path = []
|
164
168
|
no_inputs = true
|
@@ -225,7 +229,6 @@ def delete_links_without_input(new_path, number_of_links, session)
|
|
225
229
|
return next_path.flatten
|
226
230
|
end
|
227
231
|
|
228
|
-
|
229
232
|
def delete_ids(new_path)
|
230
233
|
for i in 0..get_sessions_array.size - 1 do
|
231
234
|
found_session = false
|
@@ -407,7 +410,7 @@ def try_path(path_to_try)
|
|
407
410
|
if line.class == Hash then
|
408
411
|
if line.values[0] == "Anmelden" then
|
409
412
|
session.visit user_inputs("get_login_path")
|
410
|
-
hash["#{session_index}:#{session.current_path}"] =
|
413
|
+
hash["#{session_index}:#{session.current_path}"] = user_inputs("get_login_button")
|
411
414
|
if user_inputs("use_db_users") then
|
412
415
|
user_inputs("get_login_attributes").each do |field|
|
413
416
|
session.fill_in field[1], :with => user[session_index].send(field[0].to_sym)
|
@@ -425,7 +428,7 @@ def try_path(path_to_try)
|
|
425
428
|
session.fill_in field[1], :with => user_data[i]
|
426
429
|
end
|
427
430
|
end
|
428
|
-
session.
|
431
|
+
session.click_button user_inputs("get_login_button")
|
429
432
|
elsif line.values[0] == user_inputs("get_logout_path") then
|
430
433
|
hash["#{session_index}:#{session.current_path}"] = user_inputs("get_logout_path")
|
431
434
|
session.visit user_inputs("get_logout_path")
|
@@ -593,7 +596,7 @@ def find_next_user(root_path, session)
|
|
593
596
|
user_inputs("get_login_attributes").each do |la|
|
594
597
|
session.fill_in la[1], :with => user.send(la[0].to_sym)
|
595
598
|
end
|
596
|
-
session.
|
599
|
+
session.click_button user_inputs("get_login_button")
|
597
600
|
if session.current_path == root_path then
|
598
601
|
return user
|
599
602
|
end
|
@@ -710,6 +713,9 @@ def clean_and_seed_db
|
|
710
713
|
DatabaseCleaner.strategy = :truncation
|
711
714
|
DatabaseCleaner.start
|
712
715
|
DatabaseCleaner.clean
|
716
|
+
if user_inputs("use_fixtures") then
|
717
|
+
fixtures(*user_inputs("get_fixtures"))
|
718
|
+
end
|
713
719
|
load "#{Rails.root}/db/test_seeds.rb"
|
714
720
|
end
|
715
721
|
|
@@ -4,13 +4,19 @@ require 'spec_helper'
|
|
4
4
|
describe "Application" do
|
5
5
|
describe "auto_test" do
|
6
6
|
it "simulates the error" do
|
7
|
-
|
7
|
+
init_user_inputs
|
8
8
|
load "#{Rails.root}/db/test_seeds.rb"
|
9
|
+
if user_inputs("use_fixtures") then
|
10
|
+
fixtures(*user_inputs("get_fixtures"))
|
11
|
+
end
|
9
12
|
init_path
|
10
13
|
init_sessions_array
|
11
|
-
init_user_inputs
|
12
14
|
puts "Firefox is getting started..."
|
13
|
-
|
15
|
+
begin
|
16
|
+
paths = File.new("#{Rails.root}/log/new_path.log", "r")
|
17
|
+
rescue
|
18
|
+
paths = File.new("#{Rails.root}/log/paths.log","r")
|
19
|
+
end
|
14
20
|
home = "localhost:3002"
|
15
21
|
sessions = search_sessions
|
16
22
|
number_of_sessions = sessions.size
|
data/lib/tasks/auto_test.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'auto_test'
|
2
|
+
|
3
|
+
path = %x(gem which auto_test)
|
4
|
+
path = path[0..path.size-15]
|
5
|
+
|
2
6
|
namespace :auto_test do
|
3
7
|
desc "starting the test"
|
4
8
|
task :test do
|
5
|
-
puts "Running auto_test..."
|
6
|
-
sh "rails server -e test -p 3002 -d"
|
7
|
-
path = %x(gem which auto_test)
|
8
|
-
path = path[0..path.size-15]
|
9
|
+
puts "Running auto_test..."
|
9
10
|
sh "rspec '#{path}/spec/requests/auto_spec.rb' -o '#{path}/../log/rspec.txt'"
|
10
|
-
|
11
|
+
begin
|
12
|
+
sh "rm 'log/new_path.log"
|
13
|
+
rescue
|
14
|
+
end
|
11
15
|
Rake::Task["auto_test:error_calc"].invoke
|
12
|
-
Rake::Task["auto_test:stop"].invoke
|
13
16
|
end
|
14
17
|
|
15
18
|
desc "calculating the errors"
|
@@ -26,8 +29,6 @@ namespace :auto_test do
|
|
26
29
|
|
27
30
|
desc "Reducing the error path"
|
28
31
|
task :reduce_errors do
|
29
|
-
path = %x(gem which auto_test)
|
30
|
-
path = path[0..path.size-15]
|
31
32
|
puts "Reducing the error path, this could take a while..."
|
32
33
|
sh "rspec #{path}/spec/requests/error_reduction_spec.rb -o '#{path}/../log/reduce_err.txt'"
|
33
34
|
sh "rm '#{path}/../log/reduce_err.txt'"
|
@@ -36,20 +37,18 @@ namespace :auto_test do
|
|
36
37
|
|
37
38
|
desc "starting the simulation"
|
38
39
|
task :start_action_path do
|
39
|
-
path = %x(gem which auto_test)
|
40
|
-
path = path[0..path.size-15]
|
41
|
-
# paths = File.new("lib/auto_test/log/new_path.log")
|
42
|
-
# n = 0
|
43
|
-
# while line = paths.gets do
|
44
|
-
# n = n + 1
|
45
|
-
# end
|
46
|
-
# puts "Error path reduced.There are #{n} paths to be visited."
|
47
40
|
puts "Press Enter to see the path in Firefox! "
|
41
|
+
server = true
|
48
42
|
while STDIN.gets == "\n" do
|
43
|
+
if server then
|
44
|
+
sh "rails server -e test -p 3002 -d"
|
45
|
+
server = false
|
46
|
+
end
|
49
47
|
sh "rspec #{path}/spec/requests/simulation_spec.rb -o '#{path}/../log/simulation.txt'"
|
50
|
-
sh "rm '#{path}/../log/simulation.txt'"
|
51
48
|
puts "Press Enter to see the simulation again else type 'exit'."
|
52
49
|
end
|
50
|
+
Rake::Task["auto_test:stop"].invoke
|
51
|
+
|
53
52
|
end
|
54
53
|
|
55
54
|
|
data/lib/test.rb
CHANGED
@@ -321,8 +321,11 @@ module AutoTest
|
|
321
321
|
get_number_of_sessions:#{get_number_of_sessions}")
|
322
322
|
else
|
323
323
|
f.puts("get_number_of_test_runs:#{get_number_of_test_runs}
|
324
|
+
use_fixtures:#{use_fixtures}
|
324
325
|
get_login_path:#{Authentication.get_login_path}
|
326
|
+
#{if use_fixtures? then 'get_fixtures'+get_fixtures end}
|
325
327
|
get_logout_path:#{Authentication.get_logout_path}
|
328
|
+
get_login_button:#{Authentication.get_login_button}
|
326
329
|
get_login_attributes:#{Authentication.get_login_attributes}
|
327
330
|
get_number_of_sessions:#{get_number_of_sessions}
|
328
331
|
get_login_data:#{Authentication.get_login_data}
|
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.9.
|
5
|
+
version: 0.1.9.8
|
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-24 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faker
|