testmgr 0.2.0 → 0.3.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/ex1.rb +21 -0
- data/lib/testmgr/base/test_case.rb +5 -1
- data/lib/testmgr/base/test_composite.rb +21 -0
- data/lib/testmgr/base/test_report.rb +114 -43
- data/lib/testmgr/version.rb +1 -1
- metadata +21 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c788171781d05e43fe0bb67af44a10298917bdce
|
4
|
+
data.tar.gz: 30952ea5a9c7fb6b371ba34ea7178d4066340944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaf2dd58fa586a0e04ad62b201d23bc296e0c421633a5a3bee5e8712b5ef0f261f196ac62c84ae809be818383c8d4d675c893fa8d29bb24768fb8c30bd9d981
|
7
|
+
data.tar.gz: eacb47d26ede485337c6da4b1d6307d87ddfbd3a36c2cbe663415d5fceb28b984d915f85895369924b48b94621957ff21149729c67104d09a9bf2f93f090ef91
|
data/examples/ex1.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative('../lib/testmgr')
|
2
|
+
|
3
|
+
|
4
|
+
Testmgr::TestReport.instance.addRequirement('REQ-ABC')
|
5
|
+
req=Testmgr::TestReport.instance.getReq('REQ-ABC')
|
6
|
+
|
7
|
+
|
8
|
+
Testmgr::TestReport.instance.getReq('REQ-ABC').add(Testmgr::TestCase.new('visible_when', "Dynamic"))
|
9
|
+
|
10
|
+
tc = Testmgr::TestReport.instance.getReq('REQ-ABC').tc('visible_when').add(true, 'Must be true')
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
Testmgr::TestReport.instance.getReq('REQ-ABC').tc('visible_when').add(false, 'Must be false')
|
15
|
+
|
16
|
+
Testmgr::TestReport.instance.getReq('REQ-ABC').get_child('peter').add(true, 'Peter 1')
|
17
|
+
|
18
|
+
Testmgr::TestReport.instance.report()
|
19
|
+
|
20
|
+
puts Testmgr::TestReport.instance.getMetrics()
|
21
|
+
|
@@ -24,9 +24,13 @@ module Testmgr
|
|
24
24
|
@metrics[:total] > 0 && @metrics[:passed] > 0 && @metrics[:failed]==0
|
25
25
|
end
|
26
26
|
|
27
|
+
def getMetrics()
|
28
|
+
@metrics
|
29
|
+
end
|
30
|
+
|
27
31
|
def add(rc, desc)
|
28
32
|
|
29
|
-
puts __FILE__ + (__LINE__).to_s + " TestCase.add(#{rc}, #{desc})"
|
33
|
+
puts __FILE__ + (__LINE__).to_s + " TestCase.add(#{rc}, #{desc})" if Testmgr::TestReport.instance.verbose
|
30
34
|
@assertions << { :rc => rc, :description => desc }
|
31
35
|
|
32
36
|
if rc.nil?
|
@@ -60,6 +60,10 @@ module Testmgr
|
|
60
60
|
@sub_tasks.each { |task| time += task.get_time_required }
|
61
61
|
end
|
62
62
|
|
63
|
+
def totalTestCases()
|
64
|
+
@sub_tasks.length
|
65
|
+
end
|
66
|
+
|
63
67
|
def getResult()
|
64
68
|
rc=true
|
65
69
|
@sub_tasks.each do |task|
|
@@ -78,6 +82,23 @@ module Testmgr
|
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
85
|
+
def getMetrics()
|
86
|
+
m={:passed => 0, :failed => 0, :skipped => 0, :total => 0}
|
87
|
+
@sub_tasks.each do |t|
|
88
|
+
if t.is_a?(Testmgr::TestCase)
|
89
|
+
_m = t.getMetrics()
|
90
|
+
m[:total] += _m[:total]
|
91
|
+
m[:passed] += _m[:passed]
|
92
|
+
m[:failed] += _m[:failed]
|
93
|
+
m[:skipped] += _m[:skipped]
|
94
|
+
else
|
95
|
+
puts __FILE__ + (__LINE__).to_s + " Unsure here."
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
m
|
100
|
+
end
|
101
|
+
|
81
102
|
def tc(name)
|
82
103
|
child(name)
|
83
104
|
end
|
@@ -8,7 +8,8 @@ module Testmgr
|
|
8
8
|
class TestReport
|
9
9
|
include Singleton
|
10
10
|
|
11
|
-
|
11
|
+
DEFAULT_REQ='__TBD__'
|
12
|
+
|
12
13
|
attr_accessor :completed
|
13
14
|
attr_accessor :description
|
14
15
|
attr_accessor :environment_under_test
|
@@ -16,18 +17,20 @@ class TestReport
|
|
16
17
|
attr_accessor :test_list
|
17
18
|
attr_accessor :browser_under_test
|
18
19
|
attr_accessor :data_under_test
|
19
|
-
attr_accessor :drugUnderTest
|
20
20
|
attr_accessor :worksheet_under_test
|
21
21
|
attr_accessor :req_list
|
22
22
|
attr_accessor :requirements
|
23
23
|
|
24
|
+
attr_accessor :current_rec
|
24
25
|
|
25
|
-
|
26
|
+
attr_accessor :verbose
|
26
27
|
attr_accessor :generalUser
|
27
28
|
|
29
|
+
|
28
30
|
def initialize()
|
29
|
-
|
31
|
+
@verbose=false
|
30
32
|
@description=""
|
33
|
+
@current_rec = { :req => DEFAULT_REQ, :tc => DEFAULT_REQ}
|
31
34
|
@test_list = []
|
32
35
|
@req_list = []
|
33
36
|
@requirements=[]
|
@@ -36,10 +39,51 @@ class TestReport
|
|
36
39
|
@tStart=Time.now
|
37
40
|
|
38
41
|
|
39
|
-
@webApp=nil
|
40
42
|
@generalUser=GeneralUser.new()
|
43
|
+
end
|
41
44
|
|
42
|
-
|
45
|
+
def verbose
|
46
|
+
@verbose
|
47
|
+
end
|
48
|
+
|
49
|
+
def enableVerbose
|
50
|
+
@verbose=true
|
51
|
+
end
|
52
|
+
|
53
|
+
def disableVerbose
|
54
|
+
@verbose=false
|
55
|
+
end
|
56
|
+
|
57
|
+
def setCurrentReq(_r=DEFAULT_REQ)
|
58
|
+
@current_rec[:req]=_r
|
59
|
+
end
|
60
|
+
|
61
|
+
def setCurrentRequirement(_r=DEFAULT_REQ)
|
62
|
+
setReq(_r)
|
63
|
+
end
|
64
|
+
|
65
|
+
def getCurrentReq()
|
66
|
+
@current_rec[:req]
|
67
|
+
end
|
68
|
+
|
69
|
+
def getCurrentRequirement()
|
70
|
+
getReq()
|
71
|
+
end
|
72
|
+
|
73
|
+
def getCurrentTC()
|
74
|
+
@current_rec[:tc]
|
75
|
+
end
|
76
|
+
|
77
|
+
def getCurrentTestCase()
|
78
|
+
getTC()
|
79
|
+
end
|
80
|
+
|
81
|
+
def setCurrentTC(_t=DEFAULT_REQ)
|
82
|
+
@current_rec[:tc]=_t
|
83
|
+
end
|
84
|
+
|
85
|
+
def setCurrentTestCase(_t=DEFAULT_REQ)
|
86
|
+
setTC(_t)
|
43
87
|
end
|
44
88
|
|
45
89
|
def setDescription(s)
|
@@ -60,37 +104,12 @@ class TestReport
|
|
60
104
|
|
61
105
|
@tStart=Time.now()
|
62
106
|
@completed=false
|
63
|
-
|
64
|
-
# options=TestUtils.parseOptions()
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# TestReport.instance.setEnvironment(options[:env].to_sym, options[:url])
|
69
|
-
# TestReport.instance.setBrowserUnderTest(options[:browser].to_sym)
|
70
|
-
# TestReport.instance.setDataUnderTest(options[:dut])
|
71
|
-
# TestReport.instance.setWorkSheet(options[:worksheet])
|
72
|
-
#TestReport.instance.setPatientWorkSheet(options[:patient_worksheet])
|
73
|
-
# @id_under_test=options[:id]
|
74
|
-
# GeneralUser
|
75
|
-
# TestReport.instance.setLoginPassword(options[:password])
|
76
|
-
# TestReport.instance.setLoginId(options[:userid])
|
77
|
-
|
78
|
-
# TestReport.instance.setPatientClassFile(options[:patient_class_file])
|
79
107
|
end
|
80
108
|
|
81
109
|
##
|
82
110
|
# START Commands
|
83
111
|
##
|
84
112
|
|
85
|
-
def webApp()
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
def setWebApp(w)
|
90
|
-
puts __FILE__ + (__LINE__).to_s + " setWebApp(#{w.class.to_s})"
|
91
|
-
@webApp=w
|
92
|
-
end
|
93
|
-
|
94
113
|
|
95
114
|
##
|
96
115
|
# END Commands
|
@@ -123,11 +142,7 @@ class TestReport
|
|
123
142
|
end
|
124
143
|
|
125
144
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
145
|
def setLoginId(s=nil)
|
130
|
-
puts __FILE__ + (__LINE__).to_s + " setLoginId(#{s.to_s})"
|
131
146
|
@generalUser.setLoginId(s)
|
132
147
|
end
|
133
148
|
|
@@ -234,7 +249,7 @@ class TestReport
|
|
234
249
|
TestUtils.hitKey(__FILE__ + (__LINE__).to_s + " Test Fail : #{description.to_s}- HIT KEY")
|
235
250
|
end
|
236
251
|
|
237
|
-
puts __FILE__ + (__LINE__).to_s + " #{description.to_s} : #{rc.to_s}"
|
252
|
+
puts __FILE__ + (__LINE__).to_s + " #{description.to_s} : #{rc.to_s}" if @verbose
|
238
253
|
@test_list.push({ :rc => rc, :description => description})
|
239
254
|
rc
|
240
255
|
end
|
@@ -252,12 +267,12 @@ class TestReport
|
|
252
267
|
def execute(procs)
|
253
268
|
|
254
269
|
begin
|
255
|
-
puts __FILE__ + (__LINE__).to_s + " == execute() =="
|
270
|
+
puts __FILE__ + (__LINE__).to_s + " == execute() ==" if @verbose
|
256
271
|
|
257
272
|
if procs.has_key?(:setup)
|
258
273
|
procs[:setup].call
|
259
274
|
else
|
260
|
-
puts __FILE__ + (__LINE__).to_s + " | execute default setup()"
|
275
|
+
puts __FILE__ + (__LINE__).to_s + " | execute default setup()" if @verbose
|
261
276
|
TestReport.instance.setup
|
262
277
|
end
|
263
278
|
|
@@ -281,7 +296,7 @@ class TestReport
|
|
281
296
|
|
282
297
|
end
|
283
298
|
|
284
|
-
puts __FILE__ + (__LINE__).to_s + " == exit execute() =="
|
299
|
+
puts __FILE__ + (__LINE__).to_s + " == exit execute() ==" if @verbose
|
285
300
|
end
|
286
301
|
|
287
302
|
|
@@ -293,6 +308,62 @@ class TestReport
|
|
293
308
|
end
|
294
309
|
end
|
295
310
|
|
311
|
+
def _passed?(metrics)
|
312
|
+
metrics[:total] > 0 && metrics[:passed] > 0 && metrics[:failed] == 0
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
def getMetrics()
|
317
|
+
puts "\n\n== Test Metrics ==\n"
|
318
|
+
|
319
|
+
asserts_metrics={:passed => 0, :failed => 0, :skipped => 0, :total => 0, :result => nil}
|
320
|
+
|
321
|
+
tc_metrics = {:passed => 0, :failed => 0, :skipped => 0, :total => 0 }
|
322
|
+
|
323
|
+
rq_metrics = {:passed => 0, :failed => 0, :skipped => 0, :total => 0 }
|
324
|
+
|
325
|
+
rc=true
|
326
|
+
|
327
|
+
@requirements.each do |r|
|
328
|
+
puts "#{r.class.to_s}"
|
329
|
+
|
330
|
+
rq_metrics[:total]+=1
|
331
|
+
|
332
|
+
if r.is_a?(Testmgr::TestComposite)
|
333
|
+
_m=r.getMetrics
|
334
|
+
asserts_metrics[:total] += _m[:total]
|
335
|
+
asserts_metrics[:passed] += _m[:passed]
|
336
|
+
asserts_metrics[:failed] += _m[:failed]
|
337
|
+
|
338
|
+
|
339
|
+
tc_metrics[:total]+=r.totalTestCases()
|
340
|
+
if _passed?(_m)
|
341
|
+
tc_metrics[:passed]+=1
|
342
|
+
else
|
343
|
+
tc_metrics[:failed]+=1
|
344
|
+
end
|
345
|
+
|
346
|
+
else
|
347
|
+
puts "Unhandled : #{r.class.to_s}"
|
348
|
+
end
|
349
|
+
|
350
|
+
if _passed?(tc_metrics)
|
351
|
+
rq_metrics[:passed]+=1
|
352
|
+
else
|
353
|
+
rq_metrics[:failed]+=1
|
354
|
+
end
|
355
|
+
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
rc = rq_metrics[:failed] == 0 && tc_metrics[:failed] && asserts_metrics[:failed]==0
|
360
|
+
|
361
|
+
|
362
|
+
asserts_metrics[:result] = _passed?(asserts_metrics)
|
363
|
+
|
364
|
+
{ :rc => rc, :assertions => asserts_metrics, :testcases => tc_metrics, :requirements => rq_metrics }
|
365
|
+
end
|
366
|
+
|
296
367
|
def generateReport()
|
297
368
|
endTest()
|
298
369
|
|
@@ -326,10 +397,10 @@ class TestReport
|
|
326
397
|
puts "Failed : #{failed.to_s}/#{nAsserts.to_s}"
|
327
398
|
puts "Completed : #{@completed.to_s}"
|
328
399
|
puts "Browser: #{@browser_under_test.to_s}"
|
329
|
-
puts "Env : #{@environment_under_test[:name].to_s}"
|
330
|
-
puts "URL : " + @environment_under_test[:url].to_s
|
331
|
-
puts "Login : " + getLoginId().to_s
|
332
|
-
puts "DUT : " + @data_under_test.to_s
|
400
|
+
# puts "Env : #{@environment_under_test[:name].to_s}"
|
401
|
+
# puts "URL : " + @environment_under_test[:url].to_s
|
402
|
+
# puts "Login : " + getLoginId().to_s
|
403
|
+
# puts "DUT : " + @data_under_test.to_s
|
333
404
|
puts "Start/End : #{@tStart.to_s}" + " / #{@tEnd.to_s}"
|
334
405
|
elapsed_time=time_diff_milli(@tStart)
|
335
406
|
puts "Elapsed time : #{elapsed_time.to_s} msec."
|
data/lib/testmgr/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testmgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- h20dragon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
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: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
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'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
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: '0'
|
69
69
|
description: Manager test requirements, assertions, and results to create test reports.
|
@@ -73,12 +73,12 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .idea/dictionaries/pkim.xml
|
78
|
-
- .idea/encodings.xml
|
79
|
-
- .idea/testmgr.iml
|
80
|
-
- .rspec
|
81
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".idea/dictionaries/pkim.xml"
|
78
|
+
- ".idea/encodings.xml"
|
79
|
+
- ".idea/testmgr.iml"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
82
|
- CODE_OF_CONDUCT.md
|
83
83
|
- Gemfile
|
84
84
|
- LICENSE.txt
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- Rakefile
|
87
87
|
- bin/console
|
88
88
|
- bin/setup
|
89
|
+
- examples/ex1.rb
|
89
90
|
- lib/testmgr.rb
|
90
91
|
- lib/testmgr/base/abstract_test.rb
|
91
92
|
- lib/testmgr/base/general_user.rb
|
@@ -104,17 +105,17 @@ require_paths:
|
|
104
105
|
- lib
|
105
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
107
|
requirements:
|
107
|
-
- -
|
108
|
+
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
requirements:
|
112
|
-
- -
|
113
|
+
- - ">"
|
113
114
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
115
|
+
version: 1.3.1
|
115
116
|
requirements: []
|
116
117
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.6.2
|
118
119
|
signing_key:
|
119
120
|
specification_version: 4
|
120
121
|
summary: General purpose test manager.
|