testmgr 0.3.2.pre → 0.3.2.1.pre

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30bcfe33a3d3440a6a4e12ffc0d2bc24ad2aaa8f
4
- data.tar.gz: a09aa6cd802d14829567ee94673a50ec1bfb866d
3
+ metadata.gz: 8f99cf344f690cd71d7922ae07bd9cfcc08a698f
4
+ data.tar.gz: 4449ba522a93a0abe51f06f6be3b65cb9d5e7cd2
5
5
  SHA512:
6
- metadata.gz: 80cc826e99cce045e38eaa1d18da6ed253246a8c87b5d113a8f3a11596ea58741ad5abca6d18f44d60700d297e7a2ae599a01f630342af0af130d61e607aed95
7
- data.tar.gz: 1d327f1f8108681bb3e6051d8b5ec10d8ced3c080e94d6a35b5a9ae0f6878e38e9e2e24b4b501fe3c63559219c890a54f8f30a807f45f614c2ff96463a06faea
6
+ metadata.gz: 4e9e74f515d022af1f3be4c9beedfc7a14ad971d3d12d1f531c92f206278b442f609433731961d30507efdcc666093f518094d55334ddd098e6becab3bdd4af0
7
+ data.tar.gz: 9816b682a6d0de83474f6374049d6ee498eec9bb6a47e370ac2d1883a6af786022b86a5d3e8829ee54a5bede75d5040fb899cb3b680340cd7347d96ede17bd5b
data/.idea/testmgr.iml CHANGED
@@ -2,11 +2,7 @@
2
2
  <module type="RUBY_MODULE" version="4">
3
3
  <component name="FacetManager">
4
4
  <facet type="gem" name="Ruby Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
- <option name="GEM_APP_TEST_PATH" value="" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
- </configuration>
5
+ <configuration />
10
6
  </facet>
11
7
  </component>
12
8
  <component name="NewModuleRootManager">
data/README.md CHANGED
@@ -22,7 +22,14 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Testmgr::TestReport.instance.setDescription("My Example")
26
+ Testmgr::TestReport.instance.getReq('New Req').get_child('Login').add(true, "This is a passing assertion")
27
+ Testmgr::TestReport.instance.getReq('New Req').get_child('Login').add(false, "This is a failed assertion")
28
+ Testmgr::TestReport.instance.getReq('New Req').get_child('Login').add(nil, "This is a skipped assertion")
29
+
30
+ ## JUNIT XSD
31
+
32
+ http://llg.cubic.org/docs/junit/
26
33
 
27
34
  ## Development
28
35
 
@@ -32,11 +39,17 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
39
 
33
40
  ## Run unit tests
34
41
 
35
- bundle exec rake spec
42
+ Run the unit tests:
43
+
44
+ $ bundle exec rake spec
45
+
46
+ to run a single spec,
47
+
48
+ $ rspec spec/tap_sec.rb
36
49
 
37
50
  ## Build
38
51
 
39
- bundle exec rake build
52
+ $ bundle exec rake build
40
53
 
41
54
  ## Contributing
42
55
 
@@ -28,10 +28,11 @@ module Testmgr
28
28
  @metrics
29
29
  end
30
30
 
31
- def add(rc, desc)
31
+ def add(rc, desc, sec=nil)
32
32
 
33
33
  puts __FILE__ + (__LINE__).to_s + " TestCase.add(#{rc}, #{desc})" if Testmgr::TestReport.instance.verbose
34
- @assertions << { :rc => rc, :description => desc }
34
+
35
+ @assertions << { :rc => rc, :description => desc , :time => sec}
35
36
 
36
37
  if rc.nil?
37
38
  @metrics[:skipped]+=1
@@ -128,6 +129,44 @@ module Testmgr
128
129
  s
129
130
  end
130
131
 
132
+
133
+ def junitReport(className, doc)
134
+ tapPrint(className, doc)
135
+ end
136
+
137
+ # JUNIT
138
+ def tapPrint(className, doc, seconds=nil)
139
+ i=0
140
+ @assertions.each do |a|
141
+ ts = Nokogiri::XML::Node.new('testcase', doc)
142
+ ts.set_attribute('classname', "#{className}.#{@test_id}")
143
+ ts.set_attribute('name', a[:description])
144
+ ts.set_attribute('time', a[:time].to_s)
145
+
146
+ if !seconds.nil?
147
+ ts.set_attribute('time', seconds)
148
+ end
149
+
150
+ if a[:rc].nil?
151
+ skipped=Nokogiri::XML::Node.new('skipped', ts)
152
+ ts.add_child(skipped)
153
+ elsif !a[:rc]
154
+ failed=Nokogiri::XML::Node.new('failure', ts)
155
+ failed.set_attribute('message', "test failure")
156
+ failed.content="Assertion failed"
157
+ ts.add_child(failed)
158
+ elsif a[:rc]
159
+ # Passed
160
+ else
161
+ raise "UNKNOWN_CLASS_Type: #{a}"
162
+ end
163
+
164
+ doc.add_child(ts)
165
+ i+=1
166
+ end
167
+
168
+ end
169
+
131
170
  end
132
171
 
133
172
 
@@ -73,15 +73,42 @@ module Testmgr
73
73
  rc
74
74
  end
75
75
 
76
+
76
77
  def print
77
- # puts __FILE__ + (__LINE__).to_s + " -- print( #{@name} ) --"
78
+ # puts __FILE__ + (__LINE__).to_s + " -- print( #{@name} ) --"
78
79
  puts "REQ : #{@name} : #{@sub_tasks.length.to_s} test cases."
79
80
  @sub_tasks.each do |task|
80
- # puts __FILE__ + (__LINE__).to_s + " ** #{task.class.to_s} **"
81
+ # puts __FILE__ + (__LINE__).to_s + " ** #{task.class.to_s} **"
81
82
  task.print
82
83
  end
83
84
  end
84
85
 
86
+ def tapPrint(doc)
87
+ # puts __FILE__ + (__LINE__).to_s + " -- print( #{@name} ) --"
88
+
89
+ className=@name
90
+
91
+ # puts "TAP.REQ : #{@name} : #{@sub_tasks.length.to_s} test cases."
92
+
93
+ ts = Nokogiri::XML::Node.new('testsuite', doc)
94
+ ts['name']=className
95
+ ts['tests']=getMetrics()[:total]
96
+
97
+ doc.root.add_child(ts)
98
+
99
+ @sub_tasks.each do |task|
100
+ # puts __FILE__ + (__LINE__).to_s + " ** #{task.class.to_s} **"
101
+
102
+ if task.is_a?(Testmgr::TestCase)
103
+ node=task.tapPrint(className, ts)
104
+ # ts.root.add_child(node)
105
+ else
106
+ raise "ExpectedTestCase"
107
+ end
108
+
109
+ end
110
+ end
111
+
85
112
  def getMetrics()
86
113
  m={:passed => 0, :failed => 0, :skipped => 0, :total => 0}
87
114
  @sub_tasks.each do |t|
@@ -1,6 +1,8 @@
1
1
 
2
2
  require 'singleton'
3
3
 
4
+ require 'nokogiri'
5
+
4
6
  #require 'general_user'
5
7
 
6
8
  module Testmgr
@@ -309,7 +311,6 @@ class TestReport
309
311
  puts __FILE__ + (__LINE__).to_s + " == exit execute() ==" if @verbose
310
312
  end
311
313
 
312
-
313
314
  def report()
314
315
  puts "\n\n== Test Report ==\n"
315
316
 
@@ -318,6 +319,49 @@ class TestReport
318
319
  end
319
320
  end
320
321
 
322
+
323
+ def junitReport(fullPath=nil)
324
+ rc=nil
325
+
326
+ doc = Nokogiri::XML("<testsuites></testsuites>")
327
+
328
+ @requirements.each do |r|
329
+
330
+ if r.is_a?(Testmgr::TestComposite)
331
+
332
+ metrics = r.getMetrics()
333
+
334
+ # m={:passed => 0, :failed => 0, :skipped => 0, :total => 0}
335
+ # puts __FILE__ + (__LINE__).to_s + " <testsuite name=\"#{r.get_name}\" errors=\"#{metrics[:failed]}\" total=\"#{metrics[:total]}\" >"
336
+ r.tapPrint(doc)
337
+ else
338
+ raise "WhatIsThis"
339
+ end
340
+
341
+ end
342
+
343
+ if fullPath.nil?
344
+ rc=doc.to_s
345
+ elsif fullPath.is_a?(String)
346
+
347
+ begin
348
+ open(fullPath, 'w') do |f|
349
+ f << doc.to_s
350
+ end
351
+
352
+ rc=true
353
+
354
+ rescue Errno::ENOENT => ex
355
+ puts "Exception: Testmgr::TestReport.tapReport - #{ex.class}"
356
+ puts ex.backtrace
357
+ end
358
+
359
+ end
360
+
361
+ rc
362
+ end
363
+
364
+
321
365
  def _skipped?(metrics)
322
366
  metrics[:total] == 0 && metrics[:passed] == 0 && metrics[:failed] == 0
323
367
  end
@@ -1,3 +1,3 @@
1
1
  module Testmgr
2
- VERSION = "0.3.2.pre"
2
+ VERSION = "0.3.2.1.pre"
3
3
  end
data/testmgr.gemspec CHANGED
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake"
32
32
  spec.add_development_dependency "rspec"
33
33
  spec.add_development_dependency "json"
34
+ spec.add_development_dependency "nokogiri"
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testmgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.pre
4
+ version: 0.3.2.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-04-22 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Manager test requirements, assertions, and results to create test reports.
70
84
  email:
71
85
  - h20dragon@outlook.com