actir 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fe573a920382f2ad7315697bcb620fc97e2c06b
4
- data.tar.gz: 09ec1a2c24d202158c6adf7a60deacda8bac7c23
3
+ metadata.gz: 63484bd91244d1e657e19c9675c8a22169c8b2a4
4
+ data.tar.gz: 13554f3aaee561ebbe17d5db9024ff503e460bf8
5
5
  SHA512:
6
- metadata.gz: b663a8f7b7af8edb7055769c437b5922d130e0c453d25ac1d3660692a3ee8952e15f47c35ed02fe5dc4eb8ded2f7043e549859ad1dc9a8cf8292abaf17cdd20d
7
- data.tar.gz: 9fa74d0d701b9aaa3695e4e24456b4a5bcbf13eaf5a6a455a6149650d3970376411ebea0e203b07e09ce2a1f2a9048d74db8a00a5071cb16c1a867b076bd608b
6
+ metadata.gz: 35a527b6b952aef0c789e4d9293dfeec17a5e7b4df8cdf45c2bb60a62cd0d034ef1c1043861dcd2f942eb6c1cea0955644a91d90f7792f811cd2832f30fda5e2
7
+ data.tar.gz: a65b3aeae8c43de758746b78060c4cf73845bd54aa13a616558e5c43f7eabb0478dc5768446c27ab743ad5966d4c22bfcacfeee3e2318365eea64b739d0dd882
@@ -82,7 +82,7 @@ module Actir
82
82
  result = run_tests(group, p_num, num_processes, options, address[p_num])
83
83
  #从结果中取出失败用例重跑
84
84
  if ( result[:exit_status] != 0 ) && ( re_run_times > 0 )
85
- result = Actir::ParallelTests::Test::Rerun.re_run_tests(result, p_num, num_processes, options, address[p_num], re_run_times)
85
+ result = re_run_tests(result, p_num, num_processes, options, address[p_num], re_run_times)
86
86
  end
87
87
  result
88
88
  end
@@ -106,6 +106,10 @@ module Actir
106
106
  end
107
107
  end
108
108
 
109
+ def re_run_tests(result, process_number, num_processes, options, address, re_run_times)
110
+ Actir::ParallelTests::Test::Rerunner.re_run_tests(result, process_number, num_processes, options, address, re_run_times)
111
+ end
112
+
109
113
  def report_output(result, lock)
110
114
  lock.flock File::LOCK_EX
111
115
  $stdout.puts result[:stdout]
@@ -268,8 +272,9 @@ module Actir
268
272
 
269
273
  def load_runner(type)
270
274
  require "actir/parallel_tests/#{type}/runner"
271
- require "actir/parallel_tests/#{type}/re_run"
272
- require "actir/parallel_tests/test/logger"
275
+ require "actir/parallel_tests/#{type}/rerunner"
276
+ require "actir/parallel_tests/#{type}/logger"
277
+ require "actir/parallel_tests/#{type}/result"
273
278
  runner_classname = type.split("_").map(&:capitalize).join.sub("Rspec", "RSpec")
274
279
  klass_name = "Actir::ParallelTests::#{runner_classname}::Runner"
275
280
  klass_name.split('::').inject(Object) { |x, y| x.const_get(y) }
@@ -18,7 +18,7 @@ module Actir
18
18
  def print_testsuite_start(testsuite_id, testsuite_name)
19
19
  @file.puts "<div id=\"div_testsuite_#{testsuite_id}\" class=\"testsuite passed\">"
20
20
  @file.puts " <dl>"
21
- @file.puts " <dt id=\"testsuite_#{testsuite_id}\" class=\"passed\">#{h(testsuite_name)}</dt>"
21
+ @file.puts " <dt id=\"testsuite_#{testsuite_id}\" class=\"passed\">[Testsuite]: #{h(testsuite_name)}</dt>"
22
22
  end
23
23
 
24
24
  def print_testsuite_end
@@ -28,14 +28,14 @@ module Actir
28
28
 
29
29
  def print_testcase_passed(testcase_name)
30
30
  @file.puts " <dd class=\"testcase passed\">"
31
- @file.puts " <span class=\"passed_spec_name\">#{h(testcase_name)}</span>"
31
+ @file.puts " <span class=\"passed_spec_name\">[Testcase]: #{h(testcase_name)}</span>"
32
32
  @file.puts " </dd>"
33
33
  end
34
34
 
35
35
  def print_testcase_failed(testcase_name, backtrace, failure_number)
36
36
  @file.puts " <dd class=\"testcase failed\">"
37
- @file.puts " <span class=\"failed_spec_name\">#{h(testcase_name)}</span>"
38
- @file.puts " <div id=\"testtab\" style=\"float:right\"><a class=\"expand\" href=\"#\" onClick=\"Effect('failure_#{failure_number}',this.parentNode.id);\" >+</a> </div>"
37
+ @file.puts " <span class=\"failed_spec_name\">[testcase]: #{h(testcase_name)}</span>"
38
+ @file.puts " <div id=\"testtab_#{failure_number}\" style=\"float:right\"><a class=\"expand\" href=\"#\" onClick=\"Effect('failure_#{failure_number}',this.parentNode.id);\" >+</a> </div>"
39
39
  @file.puts " <div class=\"failure\" id=\"failure_#{failure_number}\" style=\"display:none;\">"
40
40
  @file.puts " <div class=\"backtrace\"><pre>#{h(backtrace)}</pre></div>"
41
41
  @file.puts " </div>"
@@ -44,7 +44,7 @@ module Actir
44
44
 
45
45
  def print_summary(testcase_count, failure_count)
46
46
  totals = "#{testcase_count} testcase#{'s' unless testcase_count == 1}, "
47
- totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
47
+ totals << "#{failure_count} failure#{'s' unless failure_count <= 1 }"
48
48
 
49
49
  # formatted_duration = "%.5f" % duration
50
50
 
@@ -82,7 +82,7 @@ module Actir
82
82
 
83
83
  <div id="test-header">
84
84
  <div id="label">
85
- <h1>Test Cases Result</h1>
85
+ <h1>UI-Test Report</h1>
86
86
  </div>
87
87
 
88
88
  <div id="display-filters">
@@ -215,7 +215,7 @@ EOF
215
215
 
216
216
  GLOBAL_STYLES = <<-EOF
217
217
  #test-header {
218
- background: #65C400; color: #fff; height: 4em;
218
+ background: #03b401; color: #fff; height: 4em;
219
219
  }
220
220
 
221
221
  .test-report h1 {
@@ -265,7 +265,7 @@ dl {
265
265
 
266
266
  dt {
267
267
  padding: 3px;
268
- background: #65C400;
268
+ background: #03b401;
269
269
  color: #fff;
270
270
  font-weight: bold;
271
271
  }
@@ -283,8 +283,8 @@ dd .duration {
283
283
  }
284
284
 
285
285
  dd.testcase.passed {
286
- border-left: 5px solid #65C400;
287
- border-bottom: 1px solid #65C400;
286
+ border-left: 5px solid #03b401;
287
+ border-bottom: 1px solid #03b401;
288
288
  background: #DBFFB4; color: #3D7700;
289
289
  }
290
290
 
@@ -24,7 +24,8 @@ module Actir
24
24
  testsuite_print(testsuite)
25
25
  end
26
26
 
27
- summary = {:testcase_count => @testcase_number, :failure_count => @failure_number}
27
+ summary = {:testcase_count => @testcase_number,
28
+ :failure_count => @failure_number}
28
29
  summary_print(summary)
29
30
  end
30
31
 
@@ -39,7 +40,7 @@ module Actir
39
40
  @formatter.print_testsuite_start(@testsuite_number, testsuite[:testsuite_name])
40
41
  testcases = testsuite[:testcases]
41
42
  testcases.each do |testcase|
42
- if(testcase[:succuss] == true)
43
+ if(testcase[:success] == true)
43
44
  testcase_passed_print(testcase[:testcase_name])
44
45
  else
45
46
  testcase_failed_print(testcase[:testcase_name], testcase[:detail])
@@ -1,7 +1,7 @@
1
1
  module Actir
2
2
  module ParallelTests
3
3
  module Test
4
- class Rerun < Runner
4
+ class Rerunner < Runner
5
5
 
6
6
  class << self
7
7
 
@@ -75,6 +75,10 @@ module Actir
75
75
  log_str = "[re_run_tests]: \n" + result[:stdout]
76
76
  Actir::ParallelTests::Test::Logger.log(log_str, process_number)
77
77
  end
78
+
79
+ #从result中获取执行结果用于生成测试报告
80
+ Actir::ParallelTests::Test::Result.get_testsuite_detail(result, :rerunner)
81
+
78
82
  return result
79
83
  end
80
84
 
@@ -86,11 +90,11 @@ module Actir
86
90
  testfile = ""
87
91
  result_array.each do |result|
88
92
  #取出执行失败的用例文件名称和用例名称
89
- case result
90
- when failure_tests_name_reg
93
+ if (result =~ failure_tests_name_reg) || (result =~ error_tests_name_reg)
91
94
  #范例:"testhehe(TestHehe)"
92
95
  testcase = $1
93
- when failure_tests_file_reg
96
+ end
97
+ if result =~ failure_tests_file_reg
94
98
  #范例:"testcode/test_tt/test_hehe.rb:8:in `xxxx'"
95
99
  testfile = $1
96
100
  end
@@ -126,18 +130,23 @@ module Actir
126
130
 
127
131
  #判断是否有用例失败
128
132
  def any_test_failed?(result)
129
- result[:exit_status] != 0
133
+ Actir::ParallelTests::Test::Result.any_test_failed?(result)
130
134
  end
131
135
 
132
- #获取失败用例文件名的正则
133
- def failure_tests_file_reg
134
- /(.+\/test.+rb):\d+:in\s`.+'/
135
- #/^Loaded\ssuite\s(.+)/
136
+ #获取错误用例名的正则
137
+ def error_tests_name_reg
138
+ Actir::ParallelTests::Test::Result.error_tests_name_reg
136
139
  end
137
140
 
138
141
  #获取失败用例名的正则
139
142
  def failure_tests_name_reg
140
- /(test.+)\(.+\):/
143
+ Actir::ParallelTests::Test::Result.failure_tests_name_reg
144
+ end
145
+
146
+ #获取失败用例文件名的正则
147
+ def failure_tests_file_reg
148
+ /(.+\/test.+rb):\d+:in\s`.+'/
149
+ #/^Loaded\ssuite\s(.+)/
141
150
  end
142
151
 
143
152
  #获取失败数据的正则
@@ -0,0 +1,141 @@
1
+ module Actir
2
+ module ParallelTests
3
+ module Test
4
+ class Result
5
+
6
+ class << self
7
+
8
+ #
9
+ # 通过结果判断测试套的详细信息
10
+ #
11
+ # 将测试套和测试用例的详细信息写入全局变量$testsuites中
12
+ #
13
+ def get_testsuite_detail(test_result, mode = :runner)
14
+ $testsuites = [] unless $testsuites
15
+ if mode == :runner
16
+ get_run_test_info(test_result)
17
+ end
18
+
19
+ #如果有用例失败,则记录详细信息,否则不需要
20
+ if any_test_failed?(test_result)
21
+ failure_detail_hash = get_testfailed_detail(test_result)
22
+ $testsuites.each do |testsuite|
23
+ testcases = testsuite[:testcases]
24
+ testcases.each do |testcase|
25
+ #标识用例是否执行失败
26
+ fail_flag = 0
27
+ failure_detail_hash.each do |testcase_failure, detail|
28
+ if testcase_failure == testcase[:testcase_name]
29
+ testcase[:success] = false
30
+ testcase[:detail] = detail
31
+ fail_flag = 1
32
+ #从hash表中移除
33
+ failure_detail_hash.delete(testcase_failure)
34
+ end
35
+ end
36
+ if fail_flag == 0
37
+ testcase[:success] = true
38
+ testcase[:detail] = nil
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def get_run_test_info(test_result)
46
+ output = test_result[:stdout]
47
+ output.scan(/^(\[suite start\])([^\.]*)(\[suite end\])$/).each do |suite|
48
+ suitename = suite[1].scan(/^(suitname:\s*)([\d\w]*)/)[0][1]
49
+ cases = suite[1].scan(/^(testcase:\s*)([\d\w]*)/).inject([]) do |cases,testcase|
50
+ cases << {:testcase_name => testcase[1], :success => true, :detail => nil}
51
+ end
52
+ # 如果testsuites中已存在此用例的信息,说明这个用例执行了rerun,就不再次添加了
53
+ is_case_exist = $testsuites.inject(false) do |is_case_exist, testsuite|
54
+ if testsuite.has_value?(suitename)
55
+ is_case_exist = true
56
+ break
57
+ end
58
+ is_case_exist
59
+ end
60
+ if(is_case_exist == false)
61
+ testsuite = {:testsuite_name => suitename, :testcases =>cases}
62
+ $testsuites << testsuite
63
+ end
64
+ end
65
+ end
66
+
67
+ #
68
+ # 通过结果判断失败用例,获取失败用例的详细信息
69
+ #
70
+ # 将测试套和测试用例的详细信息写入全局变量$testsuites中
71
+ #
72
+ def get_testfailed_detail(test_result)
73
+ result_array = test_result[:stdout].split("\n")
74
+ failure_detail_hash = {}
75
+ testcase = ""
76
+ detail = ""
77
+ record_detail_switch = 0
78
+
79
+ result_array.each do |result|
80
+ record_detail_switch = 0 if result =~ failure_or_error_switch_off
81
+ #遇到错误信息,开启记录错误信息开关
82
+ record_detail_switch = 1 if result =~failure_or_error_switch_on
83
+
84
+ if record_detail_switch == 1
85
+ detail += result + "\n"
86
+ end
87
+
88
+ if (result =~ failure_tests_name_reg) || (result =~ error_tests_name_reg)
89
+ testcase = $1
90
+ end
91
+
92
+ if testcase != "" && detail != "" && record_detail_switch == 0
93
+ failure_detail_hash[testcase] = detail
94
+ testcase = ""
95
+ detail = ""
96
+ end
97
+ end
98
+
99
+ failure_detail_hash
100
+ end
101
+
102
+
103
+
104
+ #判断是否有用例失败
105
+ def any_test_failed?(result)
106
+ result[:exit_status] != 0
107
+ end
108
+
109
+ #获取错误用例名的正则
110
+ def error_tests_name_reg
111
+ /^Error:\s(test.+)\(.+\):/
112
+ end
113
+
114
+ #获取失败用例名的正则
115
+ def failure_tests_name_reg
116
+ /^Failure:\s(test.+)\(.+\)/
117
+ end
118
+
119
+ def test_info_swtich_on
120
+ /^\[suite start\]/
121
+ end
122
+
123
+ def test_info_swtich_off
124
+ /^\[suite end\]/
125
+ end
126
+
127
+ def failure_or_error_switch_on
128
+ /^Failure:|^Error:/
129
+ end
130
+
131
+ def failure_or_error_switch_off
132
+ /^===============================================================================$/
133
+ end
134
+
135
+
136
+ end
137
+
138
+ end
139
+ end
140
+ end
141
+ end
@@ -48,6 +48,10 @@ module Actir
48
48
  log_str = "[run_tests]: \n" + result[:stdout]
49
49
  Actir::ParallelTests::Test::Logger.log(log_str, process_number)
50
50
  end
51
+
52
+ #从result中获取执行结果用于生成测试报告
53
+ Actir::ParallelTests::Test::Result.get_testsuite_detail(result)
54
+
51
55
  result
52
56
  end
53
57
 
@@ -97,13 +101,6 @@ module Actir
97
101
  end.join(separator)
98
102
  cmd = "#{exports}#{separator}#{cmd}"
99
103
  output = open("|#{cmd}", "r") { |output| capture_output(output, silence) }
100
-
101
- #modify by shanmao
102
- #获取执行的测试套详细信息
103
- get_testsuite_detail(output)
104
- #获取失败的用例的详情
105
- get_testfailed_detail(output)
106
-
107
104
  #modify by Hub
108
105
  #exitstatus = $?.exitstatus
109
106
  #"$?.exitstatus" 返回的值有时有问题,不能明确标示用例执行结果是否成功
@@ -147,41 +144,6 @@ module Actir
147
144
  end
148
145
  end
149
146
 
150
- #
151
- # 通过结果判断测试套的详细信息
152
- # 将测试套和测试用例的详细信息写入全局变量$testsuites中
153
- #
154
- def get_testsuite_detail output
155
- $testsuites = [] unless $testsuites
156
- output.scan(/^(\[suite start\])([^\.][^E]*)(\[suite end\])$/).each do |suite|
157
- suitename = suite[1].scan(/^(suitname:\s*)([\d\w]*)/)[0][1]
158
- cases = suite[1].scan(/^(testcase:\s*)([\d\w]*)/).inject([]) do |cases,testcase|
159
- cases << {:testcase_name => testcase[1], :succuss => true, :detail => nil}
160
- end
161
- # 如果testsuites中已存在此用例的信息,说明这个用例执行了rerun,就不再次添加了
162
- is_case_exist = $testsuites.inject(false) do |is_case_exist, testsuite|
163
- if testsuite.has_value?(suitename)
164
- is_case_exist = true
165
- break
166
- end
167
- is_case_exist
168
- end
169
- if(is_case_exist == false)
170
- testsuite = {:testsuite_name => suitename, :testcases =>cases}
171
- $testsuites << testsuite
172
- end
173
- end
174
- # p $testsuites
175
- end
176
-
177
- #
178
- # 通过结果判断失败用例,获取失败用例的详细信息
179
- # 将测试套和测试用例的详细信息写入全局变量$testsuites中
180
- #
181
- def get_testfailed_detail output
182
-
183
- end
184
-
185
147
  #
186
148
  # 通过结果判断是否有用例失败
187
149
  # 返回失败用例的数目
data/lib/actir/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Actir
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actir
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: watir-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.6.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: selenium-webdriver
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.45'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.45'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parallel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: facets
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.9'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.7'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.7'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '10.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '10.0'
111
111
  description: Distribut automated testing framework for Web or App.
@@ -117,8 +117,8 @@ executables:
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
- - .gitignore
121
- - .travis.yml
120
+ - ".gitignore"
121
+ - ".travis.yml"
122
122
  - CODE_OF_CONDUCT.md
123
123
  - Gemfile
124
124
  - README.md
@@ -139,7 +139,8 @@ files:
139
139
  - lib/actir/parallel_tests/report/html_formatter.rb
140
140
  - lib/actir/parallel_tests/report/html_reporter.rb
141
141
  - lib/actir/parallel_tests/test/logger.rb
142
- - lib/actir/parallel_tests/test/re_run.rb
142
+ - lib/actir/parallel_tests/test/rerunner.rb
143
+ - lib/actir/parallel_tests/test/result.rb
143
144
  - lib/actir/parallel_tests/test/runner.rb
144
145
  - lib/actir/remote.rb
145
146
  - lib/actir/script/cookies_baidu.rb
@@ -159,17 +160,17 @@ require_paths:
159
160
  - lib
160
161
  required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - '>='
163
+ - - ">="
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
- - - '>='
168
+ - - ">="
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project:
172
- rubygems_version: 2.4.7
173
+ rubygems_version: 2.4.3
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Application Concurrence Test in Ruby.