rubyunit 0.4.22 → 0.4.23

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: ad3e199e65128364b0fa5fbdf84b92bcb36c4676
4
- data.tar.gz: b35fe9cf0e478f137db664ea352f8a8efd4f9577
3
+ metadata.gz: 5d88b937416b22f572f04440f7a0065216e040a5
4
+ data.tar.gz: 96c0e73090b854965d5c4153701d154c90f896fa
5
5
  SHA512:
6
- metadata.gz: 66c8aca53812dce104d189db03a21e5268530aed6902c686e9a6405126bff0201e7e12058642842de6a79042c57e8ef23be8ec545f9639d3c9c9d7ee1868ac38
7
- data.tar.gz: 8925eac31be70bc57f59d9f75dcbed7fa7149094df7c0bd53df88caaf35789ec2a247ee7347d35140f7e2bd204602a41c4d7fa3da81be3fde91dbfe443cc3bcf
6
+ metadata.gz: 8c2056ea74a124f676f30b4384a61ba5acf1dc65e2aa33c6f92677232653a0ee657c1d28e0b3ff87a580ec978289f882e4a03bcd3712f1f632aeea1797240fc1
7
+ data.tar.gz: ded6018f7b70dbbf6326eec4ecd35f1653cce8e8c6ad969622d26b9345f7c8f9e76edd63b9270c4146c32afc91f910e3c8b5a93d648e965ece20a6846c9da2c8
@@ -11,7 +11,4 @@ require 'RubyUnit'
11
11
  RubyUnit.debug = true if ARGV.include? '--debug'
12
12
 
13
13
  # Automatically load Test Sets
14
- Dir['tests/TS_*.rb'].each do |test_set|
15
- puts "Adding Test Set #{test_set}" if RubyUnit.debug
16
- require_relative test_set
17
- end
14
+ RubyUnit::TestSuite.new Dir['tests/TS_*.rb']
@@ -13,7 +13,7 @@ module RubyUnit
13
13
 
14
14
  ##
15
15
  # Current RubyUnit version
16
- VERSION = '0.4.22'
16
+ VERSION = '0.4.23'
17
17
 
18
18
  ##
19
19
  # Set debug mode
@@ -53,6 +53,8 @@ module RubyUnit
53
53
  end
54
54
  end
55
55
 
56
+ require_relative 'RubyUnit/TestSuite'
57
+ require_relative 'RubyUnit/TestSet'
56
58
  require_relative 'RubyUnit/TestCase'
57
59
  require_relative 'RubyUnit/Runner'
58
60
 
@@ -23,12 +23,12 @@ module RubyUnit
23
23
  # Create a string from the assertion data
24
24
  #
25
25
  def info
26
- s = "\n"
27
- s = "#{FAILURE}: #{message}\n" if message.length > 0
26
+ data = []
27
+ data << message if message.length > 0
28
28
  @data.each do |key, value|
29
- s << "\n#{key}:\n\t#{value.inspect}"
29
+ data << ":#{key} => #{value.inspect}"
30
30
  end
31
- s
31
+ data.join "\n"
32
32
  end
33
33
  end
34
34
  end
@@ -14,6 +14,7 @@ module RubyUnit
14
14
  @@start = nil
15
15
  @@finish = nil
16
16
 
17
+ @@i = 0
17
18
  def self.record result
18
19
  @@results << result
19
20
 
@@ -46,28 +47,40 @@ module RubyUnit
46
47
  @@finish
47
48
  end
48
49
 
50
+ def self.report_head result
51
+ puts
52
+ puts "#{@@i += 1}) #{result.test_case}::#{result.test}(#{result.params})"
53
+ puts result.error.class.to_s + ": " + result.error.message
54
+ end
55
+
56
+ def self.report_info result, trace = true
57
+ puts
58
+ puts result.error.info if result.error.respond_to? :info
59
+ puts result.error.backtrace * "\n" if trace
60
+ end
61
+
49
62
  def self.report type, results = [], trace = true
63
+ @@i = 0
50
64
  puts "\n#{results.count} #{type}:\n" if results.count > 0
51
65
  results.each_with_index do |result, i|
52
- puts "\n#{i + 1}) #{result.test_case}::#{result.test}(#{result.params})"
53
- puts "#{result.error.class}: #{result.error.message}"
54
- puts result.error.backtrace * "\n" if trace
66
+ report_head result
67
+ report_info result, trace
55
68
  end
56
69
  end
57
70
 
58
- def self.errors
71
+ def self.report_errors
59
72
  report 'Errors in Tests', @@errors
60
73
  end
61
74
 
62
- def self.failures
75
+ def self.report_failures
63
76
  report 'Failed Tests', @@fail
64
77
  end
65
78
 
66
- def self.skips
79
+ def self.report_skips
67
80
  report 'Skipped Tests', @@skip, false
68
81
  end
69
82
 
70
- def self.incompletes
83
+ def self.report_incompletes
71
84
  report 'Incomplete Tests', @@incomplete, false
72
85
  end
73
86
 
@@ -75,15 +88,67 @@ module RubyUnit
75
88
  @@fail.count + @@errors.count
76
89
  end
77
90
 
78
- def self.stats
79
- elapsed = @@finish - @@start
80
- inverse = Rational(elapsed.to_r.denominator,elapsed.to_r.numerator)
81
- puts
82
- puts "Tests Complete in #{elapsed} seconds!"
83
- puts "%.3f tests/s, %.3f assertions/s" % [(tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
84
- puts "%d Assertions, %d Skipped Tests, %d Incomplete Tests" % [TestCase.assertions, @@skip.count, @@incomplete.count]
85
- puts "%d Tests, %d Errors, %d Failures" % [tests, @@errors.count, @@fail.count]
91
+ def self.per_second count
92
+ return 0 if @@start.nil?
93
+ finish = @@finish.nil? ? Time.new : @@finish
94
+ elapsed = (finish - @@start).to_r
95
+ (count * (Rational(elapsed.denominator, elapsed.numerator))).to_f
96
+ end
97
+
98
+ def self.report_timed
99
+ timed_stats.each do |key, duration|
100
+ puts "#{key} in #{duration} seconds"
101
+ end
102
+ end
103
+
104
+ def self.timed_stats
105
+ timed = {}
106
+ timed['Tests Completed'] = @@finish - @@start
107
+ timed
108
+ end
109
+
110
+ def self.report_rated
111
+ s = ''
112
+ rated_stats.each do |rated, count|
113
+ s << "%.3f #{rated}/s" % [per_second(count)]
114
+ s << ', ' unless rated_stats.keys.last == rated
115
+ end
116
+ puts s
117
+ end
118
+
119
+ def self.rated_stats
120
+ rated = {}
121
+ rated['Tests'] = tests
122
+ rated['Assertions'] = TestCase.assertions
123
+ rated
124
+ end
125
+
126
+ def self.report_counted
127
+ s = ''
128
+ counted_stats.each do |counted, count|
129
+ s << "#{count} #{counted}"
130
+ s << ', ' unless counted_stats.keys.last == counted
131
+ end
132
+ puts s
133
+ end
134
+
135
+ def self.counted_stats
136
+ counted = rated_stats.clone
137
+ counted['Skipped Tests'] = @@skip.count unless @@skip.count.zero?
138
+ counted['Incomplete Tests'] = @@incomplete.count unless @@incomplete.count.zero?
139
+ counted['Failed Tests'] = @@fail.count
140
+ counted
141
+ end
142
+
143
+ def self.report_stats
86
144
  puts
145
+ report_timed
146
+ report_rated
147
+ report_counted
148
+ end
149
+
150
+ def self.stats
151
+ {:timed=>timed_stats,:rate=>rated_stats,:count=>counted_stats}
87
152
  end
88
153
  end
89
154
  end
@@ -78,11 +78,11 @@ module RubyUnit
78
78
  # report # => nice and simple
79
79
  #
80
80
  def report
81
- Report.errors
82
- Report.skips
83
- Report.incompletes
84
- Report.failures
85
- Report.stats
81
+ Report.report_errors
82
+ Report.report_skips
83
+ Report.report_incompletes
84
+ Report.report_failures
85
+ Report.report_stats
86
86
  end
87
87
  end
88
88
 
@@ -0,0 +1,28 @@
1
+ module RubyUnit
2
+ ##
3
+ # Test Sets are a collection of Test Cases
4
+ class TestSet
5
+ ##
6
+ # Create a test set and import test cases.
7
+ def initialize test_cases
8
+ $:.unshift '.' unless $:.include? '.'
9
+ import test_cases
10
+ end
11
+
12
+ ##
13
+ # Import the test cases for this test set
14
+ def import test_cases
15
+ raise TypeError, "File list must be an Array, got #{test_cases.class}" unless test_cases.is_a? Array
16
+ test_cases.each do |test_case|
17
+ puts "%20s : %s" % ['Adding ' + self.class.type, test_case] if RubyUnit.debug
18
+ require test_case
19
+ end
20
+ end
21
+
22
+ ##
23
+ # Defining type of files includes for RubyUnit::TestSuite used with --debug
24
+ def self.type
25
+ 'Test Case'
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'TestSet'
2
+
3
+ module RubyUnit
4
+ TYPE = 'Test Set'
5
+
6
+ ##
7
+ # Test Suites are a collection of test sets
8
+ # TestSuite is a larger concept of TestSet
9
+ class TestSuite < TestSet
10
+
11
+ ##
12
+ # Defining type of files includes for RubyUnit::TestSuite used with --debug
13
+ def self.type
14
+ 'Test Set'
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/AssertionFailure/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/AssertionFailure/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/AssertionMessage/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/AssertionMessage/TC_*.rb"]
@@ -57,7 +57,4 @@ module AssertionsTests
57
57
  end
58
58
 
59
59
  # Test Cases
60
- Dir["#{File.dirname(__FILE__)}/Assertions/TC_*.rb"].each do |test_case|
61
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
62
- require test_case
63
- end
60
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/Assertions/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/IncompleteTest/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/IncompleteTest/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/RubyUnit/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/RubyUnit/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/Runner/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/Runner/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/SkippedTest/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/SkippedTest/TC_*.rb"]
@@ -3,7 +3,4 @@
3
3
  require 'RubyUnit'
4
4
 
5
5
  # Test Cases
6
- Dir["#{File.dirname(__FILE__)}/TestCase/TC_*.rb"].each do |test_case|
7
- puts "Adding Test Case #{test_case}" if RubyUnit.debug
8
- require test_case
9
- end
6
+ RubyUnit::TestSet.new Dir["#{File.dirname(__FILE__)}/TestCase/TC_*.rb"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.22
4
+ version: 0.4.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Clower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,6 +59,8 @@ files:
59
59
  - lib/RubyUnit/Runner.rb
60
60
  - lib/RubyUnit/SkippedTest.rb
61
61
  - lib/RubyUnit/TestCase.rb
62
+ - lib/RubyUnit/TestSet.rb
63
+ - lib/RubyUnit/TestSuite.rb
62
64
  - tests/AssertionFailure/TC_Class.rb
63
65
  - tests/AssertionFailure/TC_Instance.rb
64
66
  - tests/AssertionFailure/data/Class.rb