minitest 4.7.5 → 5.0.7
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/.autotest +21 -8
- data/History.txt +132 -12
- data/Manifest.txt +6 -0
- data/README.txt +109 -59
- data/Rakefile +3 -31
- data/design_rationale.rb +2 -2
- data/lib/hoe/minitest.rb +9 -5
- data/lib/minitest/assertions.rb +649 -0
- data/lib/minitest/autorun.rb +6 -6
- data/lib/minitest/benchmark.rb +92 -85
- data/lib/minitest/expectations.rb +281 -0
- data/lib/minitest/hell.rb +3 -5
- data/lib/minitest/mock.rb +40 -13
- data/lib/minitest/parallel_each.rb +59 -12
- data/lib/minitest/pride.rb +3 -111
- data/lib/minitest/pride_plugin.rb +143 -0
- data/lib/minitest/spec.rb +45 -312
- data/lib/minitest/test.rb +287 -0
- data/lib/minitest/unit.rb +32 -1402
- data/lib/minitest.rb +733 -0
- data/test/minitest/metametameta.rb +41 -30
- data/test/minitest/test_minitest_benchmark.rb +11 -9
- data/test/minitest/test_minitest_mock.rb +116 -32
- data/test/minitest/test_minitest_reporter.rb +313 -0
- data/test/minitest/test_minitest_spec.rb +52 -63
- data/test/minitest/test_minitest_unit.rb +231 -235
- data.tar.gz.sig +0 -0
- metadata +17 -10
- metadata.gz.sig +2 -1
data/.autotest
CHANGED
|
@@ -4,18 +4,31 @@ require 'autotest/restart'
|
|
|
4
4
|
require 'autotest/rcov' if ENV['RCOV']
|
|
5
5
|
|
|
6
6
|
Autotest.add_hook :initialize do |at|
|
|
7
|
-
at.testlib = 'minitest/
|
|
7
|
+
at.testlib = 'minitest/autorun'
|
|
8
|
+
|
|
9
|
+
bench_tests = %w(TestMinitestBenchmark)
|
|
10
|
+
mock_tests = %w(TestMinitestMock TestMinitestStub)
|
|
11
|
+
spec_tests = %w(TestMinitestReporter TestMetaStatic TestMeta
|
|
12
|
+
TestSpecInTestCase)
|
|
13
|
+
unit_tests = %w(TestMinitestGuard TestMinitestRunnable
|
|
14
|
+
TestMinitestRunner TestMinitestTest TestMinitestUnit
|
|
15
|
+
TestMinitestUnitInherited TestMinitestUnitOrder
|
|
16
|
+
TestMinitestUnitRecording TestMinitestUnitTestCase)
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
bench_tests => "test/minitest/test_minitest_benchmark.rb",
|
|
20
|
+
mock_tests => "test/minitest/test_minitest_mock.rb",
|
|
21
|
+
spec_tests => "test/minitest/test_minitest_reporter.rb",
|
|
22
|
+
unit_tests => "test/minitest/test_minitest_unit.rb",
|
|
23
|
+
}.each do |klasses, file|
|
|
24
|
+
klasses.each do |klass|
|
|
25
|
+
at.extra_class_map[klass] = file
|
|
26
|
+
end
|
|
27
|
+
end
|
|
8
28
|
|
|
9
|
-
at.extra_class_map["MiniTest::Spec"] = "test/test_minitest_spec.rb"
|
|
10
|
-
at.extra_class_map["TestMeta"] = "test/test_minitest_spec.rb"
|
|
11
|
-
at.extra_class_map["TestMiniTestUnitTestCase"] = "test/test_minitest_unit.rb"
|
|
12
|
-
at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
|
|
13
|
-
at.extra_class_map["TestMiniTestUnitRecording"]= "test/test_minitest_unit.rb"
|
|
14
|
-
at.extra_class_map["TestMiniTestStub"] = "test/test_minitest_mock.rb"
|
|
15
29
|
at.add_exception 'coverage.info'
|
|
16
30
|
at.add_exception 'coverage'
|
|
17
31
|
end
|
|
18
32
|
|
|
19
33
|
# require 'autotest/rcov'
|
|
20
34
|
# Autotest::RCov.command = 'rcov_info'
|
|
21
|
-
|
data/History.txt
CHANGED
|
@@ -1,24 +1,144 @@
|
|
|
1
|
-
===
|
|
1
|
+
=== 5.0.7 / 2013-09-05
|
|
2
|
+
|
|
3
|
+
* 2 minor enhancements:
|
|
4
|
+
|
|
5
|
+
* Added clarification about the use of thread local variables in expectations. (jemc)
|
|
6
|
+
* Added extra message about skipped tests, if any. Disable globally with $MT_NO_SKIP_MSG.
|
|
2
7
|
|
|
3
8
|
* 2 bug fixes:
|
|
4
9
|
|
|
5
|
-
*
|
|
6
|
-
*
|
|
10
|
+
* Only require minitest, not minitest/autorun in pride_plugin. (judofyr)
|
|
11
|
+
* Require rubygems in load_plugins in case you're not using minitest/autorun.
|
|
7
12
|
|
|
8
|
-
===
|
|
13
|
+
=== 5.0.6 / 2013-06-28
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
to ruby and will be put into maintenance mode there.
|
|
15
|
+
* 3 minor enhancements:
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
back.
|
|
17
|
+
* Allow stub to pass args to blocks. (swindsor)
|
|
18
|
+
* Improved warning message about minitest/autorun to address 1.9's minitest/autorun.
|
|
19
|
+
* Made minitest/test require minitest as needed. For lib writers. (erikh)
|
|
17
20
|
|
|
18
|
-
*
|
|
21
|
+
* 1 bug fix:
|
|
22
|
+
|
|
23
|
+
* Fixed missing require in minitest/test. (erikh)
|
|
24
|
+
|
|
25
|
+
=== 5.0.5 / 2013-06-20
|
|
26
|
+
|
|
27
|
+
* 6 bug fixes:
|
|
28
|
+
|
|
29
|
+
* DOH! Fixed the rest of the new casing on Minitest. (splattael)
|
|
30
|
+
* Fixed typo on minitest/mock rdoc. (mrgilman/guiceolin)
|
|
31
|
+
* Make Spec::DSL.describe_stack thread local to avoid failing on my own tests.
|
|
32
|
+
* Make a fake Time.now local to the tests so they won't interfere with real reporter timings.
|
|
33
|
+
* Make everything mockable by wrapping all 'special' methods in a smarter wrapper. (bestie)
|
|
34
|
+
* Raise ArgumentError if let name starts with 'test'. (johnmaxwell)
|
|
35
|
+
|
|
36
|
+
=== 5.0.4 / 2013-06-07
|
|
37
|
+
|
|
38
|
+
* 5 minor enhancements:
|
|
39
|
+
|
|
40
|
+
* Added AbstractReporter, defining required Reporter API to quack properly.
|
|
41
|
+
* Added doco for writing reporters.
|
|
42
|
+
* Refactored Reporter into ProgressReporter and SummaryReporter. (idea: phiggins, code:me+scotch)
|
|
43
|
+
* Refactored SummaryReporter pushing up to StatisticsReporter. (phiggins)
|
|
44
|
+
* Removed Reporter#run_and_report... cleaner, but doesn't "fit" in the API.
|
|
19
45
|
|
|
46
|
+
=== 5.0.3 / 2013-05-29
|
|
47
|
+
|
|
48
|
+
* 4 minor enhancements:
|
|
49
|
+
|
|
50
|
+
* Added Runnable.with_info_handler and Runnable.on_signal.
|
|
51
|
+
* Moved io.sync restore to Reporter#run_and_report.
|
|
52
|
+
* Refactored inner loop of Reporter#report to #to_s. Callable for status updates.
|
|
53
|
+
* Restored MT4's mid-run report (^t). (tenderlove).
|
|
54
|
+
|
|
55
|
+
=== 5.0.2 / 2013-05-20
|
|
56
|
+
|
|
57
|
+
* 3 bug fixes:
|
|
58
|
+
|
|
59
|
+
* Gem.find_files is smarter than I remember... cause I wrote it that way. *sigh* I'm getting old.
|
|
60
|
+
* Pride wasn't doing puts through its #io. (tmiller/tenderlove)
|
|
61
|
+
* Replaced Runnable#dup and Test#dup with marshal_dump/load. Too many problems cropping up on untested rails code. (tenderlove/rubys)
|
|
62
|
+
|
|
63
|
+
=== 5.0.1 / 2013-05-14
|
|
64
|
+
|
|
65
|
+
* 2 bug fixes:
|
|
66
|
+
|
|
67
|
+
* Documented Assertions' need for @assertions to be defined by the includer.
|
|
68
|
+
* Only load one plugin version per name. Tries for latest.
|
|
69
|
+
|
|
70
|
+
=== 5.0.0 / 2013-05-10
|
|
71
|
+
|
|
72
|
+
Oh god... here we go...
|
|
73
|
+
|
|
74
|
+
Minitest 5:
|
|
75
|
+
|
|
76
|
+
* 4 deaths in the family:
|
|
77
|
+
|
|
78
|
+
* MiniTest.runner is dead. No more manager objects.
|
|
79
|
+
* MiniTest::Unit#record is dead. Use a Reporter instance instead.
|
|
80
|
+
* MiniTest::Unit._run_* is dead. Runnable things are responsible for their own runs.
|
|
81
|
+
* MiniTest::Unit.output is dead. No more centralized IO.
|
|
82
|
+
|
|
83
|
+
* 12 major (oft incompatible) changes:
|
|
84
|
+
|
|
85
|
+
* Renamed MiniTest to Minitest. Your pinkies will thank me. (aliased to MiniTest)
|
|
86
|
+
* Removed MiniTest::Unit entirely. No more manager objects.
|
|
87
|
+
* Added Minitest::Runnable. Everything minitest can run subclasses this.
|
|
88
|
+
* Renamed MiniTest::Unit::TestCase to Minitest::Test (subclassing Runnable).
|
|
89
|
+
* Added Minitest::Benchmark.
|
|
90
|
+
* Your benchmarks need to move to their own subclass.
|
|
91
|
+
* Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
|
|
92
|
+
* MiniTest::Unit.after_tests moved to Minitest.after_tests
|
|
93
|
+
* MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
|
|
94
|
+
* Removed ParallelEach#grep since it isn't used anywhere.
|
|
95
|
+
* Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
|
|
96
|
+
* Runnable#run needs to return self. Allows for swapping of results as needed.
|
|
97
|
+
|
|
98
|
+
* 8 minor moves:
|
|
99
|
+
|
|
100
|
+
* Moved Assertions module to minitest/assertions.rb
|
|
101
|
+
* Moved Expectations module to minitest/expectations.rb
|
|
102
|
+
* Moved Test to minitest/test.rb
|
|
103
|
+
* Moved everything else in minitest/unit.rb to minitest.rb
|
|
104
|
+
* minitest/unit.rb is now just a small (user-test only) compatibility layer.
|
|
105
|
+
* Moved most of minitest/pride into minitest/pride_plugin.
|
|
106
|
+
* minitest/pride now just activates pride.
|
|
107
|
+
* Moved ParallelEach under Minitest.
|
|
108
|
+
|
|
109
|
+
* 9 additions:
|
|
110
|
+
|
|
111
|
+
* Added a plugin system that can extend command-line options.
|
|
112
|
+
* Added Minitest.extensions.
|
|
113
|
+
* Added Minitest.reporter (only available during startup).
|
|
114
|
+
* Added Minitest.run(args). This is the very top of any Minitest run.
|
|
115
|
+
* Added Minitest::Reporter. Everything minitest can report goes through here.
|
|
116
|
+
* Minitest.reporter is a composite so you can add your own.
|
|
117
|
+
* Added Minitest::CompositeReporter. Much easier to extend with your own reporters.
|
|
118
|
+
* Added UnexpectedError, an Assertion subclass, to wrap up errors.
|
|
119
|
+
* Minitest::Test#run is now freakin' beautiful. 47 -> 17 loc
|
|
120
|
+
|
|
121
|
+
* 11 other:
|
|
122
|
+
|
|
123
|
+
* Removed Object.infect_with_assertions (it was already dead code).
|
|
124
|
+
* Runnables are responsible for knowing their result_code (eg "." or "F").
|
|
125
|
+
* Minitest.autorun now returns boolean, not exit code.
|
|
126
|
+
* Added FAQ entry for extending via modules. (phiggins)
|
|
127
|
+
* Implement Runnable#dup to cleanse state back to test results. Helps with serialization. pair:tenderlove
|
|
128
|
+
* Moved ParallelEach under Minitest.
|
|
129
|
+
* Runnable#run needs to return self. Allows for swapping of results as needed.
|
|
130
|
+
* Minitest.init_plugins passes down options.
|
|
131
|
+
* Minitest.load_plugins only loads once.
|
|
132
|
+
* Fixed minitest/pride to work with rake test loader again. (tmiller)
|
|
20
133
|
* Added count/size to ParallelEach to fix use w/in stdlib's test/unit. :( (btaitelb)
|
|
21
|
-
|
|
134
|
+
|
|
135
|
+
* 5 voodoo:
|
|
136
|
+
|
|
137
|
+
* Removed mutex from minitest.rb (phiggins)
|
|
138
|
+
* Removed mutex from test.rb (phiggins)
|
|
139
|
+
* Removed Minitest::Reporter.synchronize (phiggins)
|
|
140
|
+
* Removed Minitest::Test.synchronize (phiggins)
|
|
141
|
+
* Upon loading minitest/parallel_each, record, capture_io and capture_subprocess_io are doped with synchronization code. (phiggins)
|
|
22
142
|
|
|
23
143
|
=== 4.7.3 / 2013-04-20
|
|
24
144
|
|
data/Manifest.txt
CHANGED
|
@@ -5,16 +5,22 @@ README.txt
|
|
|
5
5
|
Rakefile
|
|
6
6
|
design_rationale.rb
|
|
7
7
|
lib/hoe/minitest.rb
|
|
8
|
+
lib/minitest.rb
|
|
9
|
+
lib/minitest/assertions.rb
|
|
8
10
|
lib/minitest/autorun.rb
|
|
9
11
|
lib/minitest/benchmark.rb
|
|
12
|
+
lib/minitest/expectations.rb
|
|
10
13
|
lib/minitest/hell.rb
|
|
11
14
|
lib/minitest/mock.rb
|
|
12
15
|
lib/minitest/parallel_each.rb
|
|
13
16
|
lib/minitest/pride.rb
|
|
17
|
+
lib/minitest/pride_plugin.rb
|
|
14
18
|
lib/minitest/spec.rb
|
|
19
|
+
lib/minitest/test.rb
|
|
15
20
|
lib/minitest/unit.rb
|
|
16
21
|
test/minitest/metametameta.rb
|
|
17
22
|
test/minitest/test_minitest_benchmark.rb
|
|
18
23
|
test/minitest/test_minitest_mock.rb
|
|
24
|
+
test/minitest/test_minitest_reporter.rb
|
|
19
25
|
test/minitest/test_minitest_spec.rb
|
|
20
26
|
test/minitest/test_minitest_unit.rb
|
data/README.txt
CHANGED
|
@@ -90,9 +90,9 @@ Given that you'd like to test the following class:
|
|
|
90
90
|
|
|
91
91
|
=== Unit tests
|
|
92
92
|
|
|
93
|
-
require
|
|
93
|
+
require "minitest/autorun"
|
|
94
94
|
|
|
95
|
-
class TestMeme <
|
|
95
|
+
class TestMeme < Minitest::Test
|
|
96
96
|
def setup
|
|
97
97
|
@meme = Meme.new
|
|
98
98
|
end
|
|
@@ -112,7 +112,7 @@ Given that you'd like to test the following class:
|
|
|
112
112
|
|
|
113
113
|
=== Specs
|
|
114
114
|
|
|
115
|
-
require
|
|
115
|
+
require "minitest/autorun"
|
|
116
116
|
|
|
117
117
|
describe Meme do
|
|
118
118
|
before do
|
|
@@ -138,13 +138,12 @@ https://github.com/zenspider/minitest-matchers
|
|
|
138
138
|
|
|
139
139
|
=== Benchmarks
|
|
140
140
|
|
|
141
|
-
Add benchmarks to your
|
|
142
|
-
benchmarks won't run.
|
|
141
|
+
Add benchmarks to your tests.
|
|
143
142
|
|
|
144
143
|
# optionally run benchmarks, good for CI-only work!
|
|
145
|
-
require
|
|
144
|
+
require "minitest/benchmark" if ENV["BENCH"]
|
|
146
145
|
|
|
147
|
-
class TestMeme <
|
|
146
|
+
class TestMeme < Minitest::Benchmark
|
|
148
147
|
# Override self.bench_range or default range is [1, 10, 100, 1_000, 10_000]
|
|
149
148
|
def bench_my_algorithm
|
|
150
149
|
assert_performance_linear 0.9999 do |n| # n is a range value
|
|
@@ -155,9 +154,10 @@ benchmarks won't run.
|
|
|
155
154
|
|
|
156
155
|
Or add them to your specs. If you make benchmarks optional, you'll
|
|
157
156
|
need to wrap your benchmarks in a conditional since the methods won't
|
|
158
|
-
be defined.
|
|
157
|
+
be defined. In minitest 5, the describe name needs to match
|
|
158
|
+
/Bench(mark)?$/.
|
|
159
159
|
|
|
160
|
-
describe Meme do
|
|
160
|
+
describe "Meme Benchmark" do
|
|
161
161
|
if ENV["BENCH"] then
|
|
162
162
|
bench_performance_linear "my_algorithm", 0.9999 do |n|
|
|
163
163
|
100.times do
|
|
@@ -190,11 +190,11 @@ Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
-
require
|
|
193
|
+
require "minitest/autorun"
|
|
194
194
|
|
|
195
195
|
describe MemeAsker do
|
|
196
196
|
before do
|
|
197
|
-
@meme =
|
|
197
|
+
@meme = Minitest::Mock.new
|
|
198
198
|
@meme_asker = MemeAsker.new @meme
|
|
199
199
|
end
|
|
200
200
|
|
|
@@ -229,57 +229,70 @@ new non-existing method:
|
|
|
229
229
|
...
|
|
230
230
|
end
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
MiniTest::Unit.runner=(runner) provides an easy way of creating custom
|
|
235
|
-
test runners for specialized needs. Justin Weiss provides the
|
|
236
|
-
following real-world example to create an alternative to regular
|
|
237
|
-
fixture loading:
|
|
232
|
+
== Writing Extensions
|
|
238
233
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
To define a plugin, add a file named minitest/XXX_plugin.rb to your
|
|
235
|
+
project/gem. Minitest will find and require that file using
|
|
236
|
+
Gem.find_files. It will then try to call plugin_XXX_init during
|
|
237
|
+
startup. The option processor will also try to call plugin_XXX_options
|
|
238
|
+
passing the OptionParser instance and the current options hash. This
|
|
239
|
+
lets you register your own command-line options. Here's a totally
|
|
240
|
+
bogus example:
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
end
|
|
242
|
+
# minitest/bogus_plugin.rb:
|
|
245
243
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
module Minitest
|
|
245
|
+
def self.plugin_bogus_options(opts, options)
|
|
246
|
+
opts.on "--myci", "Report results to my CI" do
|
|
247
|
+
options[:myci] = true
|
|
248
|
+
options[:myci_addr] = get_myci_addr
|
|
249
|
+
options[:myci_port] = get_myci_port
|
|
250
|
+
end
|
|
252
251
|
end
|
|
253
|
-
end
|
|
254
252
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
suite.before_suite
|
|
258
|
-
super(suite, type)
|
|
259
|
-
ensure
|
|
260
|
-
suite.after_suite
|
|
253
|
+
def self.plugin_bogus_init(options)
|
|
254
|
+
self.reporter << MyCI.new(options) if options[:myci]
|
|
261
255
|
end
|
|
262
256
|
end
|
|
263
|
-
end
|
|
264
257
|
|
|
265
|
-
|
|
266
|
-
class Unit < MiniTestWithHooks::Unit
|
|
267
|
-
include TestSetupHelper
|
|
258
|
+
=== Adding custom reporters
|
|
268
259
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
260
|
+
Minitest uses composite reporter to output test results using multiple
|
|
261
|
+
reporter instances. You can add new reporters to the composite during
|
|
262
|
+
the init_plugins phase. As we saw in +plugin_bonus_init+ above, you
|
|
263
|
+
simply add your reporter instance to the composite via +<<+.
|
|
264
|
+
|
|
265
|
+
+AbstractReporter+ defines the API for reporters. You may subclass it
|
|
266
|
+
and override any method you want to achieve your desired behavior.
|
|
267
|
+
|
|
268
|
+
start :: Called when the run has started.
|
|
269
|
+
record :: Called for each result, passed or otherwise.
|
|
270
|
+
report :: Called at the end of the run.
|
|
271
|
+
passed? :: Called to see if you detected any problems.
|
|
272
|
+
|
|
273
|
+
Using our example above, here is how we might implement MyCI:
|
|
274
|
+
|
|
275
|
+
# minitest/bogus_plugin.rb
|
|
276
|
+
|
|
277
|
+
module Minitest
|
|
278
|
+
class MyCI < AbstractReporter
|
|
279
|
+
attr_accessor :results, :addr, :port
|
|
280
|
+
|
|
281
|
+
def initialize options
|
|
282
|
+
self.results = []
|
|
283
|
+
self.addr = options[:myci_addr]
|
|
284
|
+
self.port = options[:myci_port]
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def record result
|
|
288
|
+
self.results << result
|
|
289
|
+
end
|
|
274
290
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
291
|
+
def report
|
|
292
|
+
CI.connect(addr, port).send_results self.results
|
|
293
|
+
end
|
|
278
294
|
end
|
|
279
295
|
end
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
MiniTest::Unit.runner = MiniTestWithTransactions::Unit.new
|
|
283
296
|
|
|
284
297
|
== FAQ
|
|
285
298
|
|
|
@@ -315,25 +328,59 @@ Expectations are put on Object (one level down) so the Worker
|
|
|
315
328
|
fails.
|
|
316
329
|
|
|
317
330
|
You can bypass `SimpleDelegate#method_missing` by extending the worker
|
|
318
|
-
with `
|
|
331
|
+
with `Minitest::Expectations`. You can either do that in your setup at
|
|
319
332
|
the instance level, like:
|
|
320
333
|
|
|
321
334
|
before do
|
|
322
335
|
@worker = Worker.new(Object.new)
|
|
323
|
-
@worker.extend
|
|
336
|
+
@worker.extend Minitest::Expectations
|
|
324
337
|
end
|
|
325
338
|
|
|
326
339
|
or you can extend the Worker class (within the test file!), like:
|
|
327
340
|
|
|
328
341
|
class Worker
|
|
329
|
-
include ::
|
|
342
|
+
include ::Minitest::Expectations
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
=== How to share code across test classes?
|
|
346
|
+
|
|
347
|
+
Use a module. That's exactly what they're for:
|
|
348
|
+
|
|
349
|
+
module UsefulStuff
|
|
350
|
+
def useful_method
|
|
351
|
+
# ...
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
describe Blah do
|
|
356
|
+
include UsefulStuff
|
|
357
|
+
|
|
358
|
+
def test_whatever
|
|
359
|
+
# useful_method available here
|
|
360
|
+
end
|
|
330
361
|
end
|
|
331
362
|
|
|
363
|
+
Remember, `describe` simply creates test classes. It's just ruby at
|
|
364
|
+
the end of the day and all your normal Good Ruby Rules (tm) apply. If
|
|
365
|
+
you want to extend your test using setup/teardown via a module, just
|
|
366
|
+
make sure you ALWAYS call super. before/after automatically call super
|
|
367
|
+
for you, so make sure you don't do it twice.
|
|
368
|
+
|
|
369
|
+
== Prominent Projects using Minitest:
|
|
370
|
+
|
|
371
|
+
* arel
|
|
372
|
+
* journey
|
|
373
|
+
* mime-types
|
|
374
|
+
* nokogiri
|
|
375
|
+
* rails (active_support et al)
|
|
376
|
+
* rake
|
|
377
|
+
* rdoc
|
|
378
|
+
|
|
332
379
|
== Known Extensions:
|
|
333
380
|
|
|
334
|
-
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content(
|
|
381
|
+
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content("Title")).
|
|
335
382
|
minispec-metadata :: Metadata for describe/it blocks
|
|
336
|
-
(e.g. `it
|
|
383
|
+
(e.g. `it "requires JS driver", js: true do`)
|
|
337
384
|
minitest-ansi :: Colorize minitest output with ANSI colors.
|
|
338
385
|
minitest-around :: Around block for minitest. An alternative to setup/teardown dance.
|
|
339
386
|
minitest-capistrano :: Assertions and expectations for testing Capistrano recipes
|
|
@@ -350,6 +397,7 @@ minitest-emoji :: Print out emoji for your test passes, fails, and
|
|
|
350
397
|
minitest-english :: Semantically symmetric aliases for assertions and expectations.
|
|
351
398
|
minitest-excludes :: Clean API for excluding certain tests you
|
|
352
399
|
don't want to run under certain conditions.
|
|
400
|
+
minitest-filesystem :: Adds assertion and expectation to help testing filesystem contents.
|
|
353
401
|
minitest-firemock :: Makes your MiniTest mocks more resilient.
|
|
354
402
|
minitest-great_expectations :: Generally useful additions to minitest's assertions and expectations
|
|
355
403
|
minitest-growl :: Test notifier for minitest via growl.
|
|
@@ -359,6 +407,7 @@ minitest-instrument :: Instrument ActiveSupport::Notifications when
|
|
|
359
407
|
minitest-instrument-db :: Store information about speed of test
|
|
360
408
|
execution provided by minitest-instrument in database
|
|
361
409
|
minitest-libnotify :: Test notifier for minitest via libnotify.
|
|
410
|
+
minitest-line :: Run test at line number
|
|
362
411
|
minitest-macruby :: Provides extensions to minitest for macruby UI testing.
|
|
363
412
|
minitest-matchers :: Adds support for RSpec-style matchers to minitest.
|
|
364
413
|
minitest-metadata :: Annotate tests with metadata (key-value).
|
|
@@ -372,6 +421,7 @@ minitest-reporters :: Create customizable MiniTest output formats
|
|
|
372
421
|
minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
|
|
373
422
|
minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
|
|
374
423
|
minitest-spec-context :: Provides rspec-ish context method to MiniTest::Spec
|
|
424
|
+
minitest-spec-expect :: Expect syntax for MiniTest::Spec - expect(sequences).to_include :celery_man
|
|
375
425
|
minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
|
|
376
426
|
minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
|
|
377
427
|
minitest-stub-const :: Stub constants for the duration of a block
|
|
@@ -416,11 +466,11 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
|
416
466
|
sudo gem install minitest
|
|
417
467
|
|
|
418
468
|
On 1.9, you already have it. To get newer candy you can still install
|
|
419
|
-
the gem,
|
|
469
|
+
the gem, and then requiring "minitest/autorun" should automatically
|
|
470
|
+
pull it in. If not, you'll need to do it yourself:
|
|
420
471
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
require 'minitest/autorun'
|
|
472
|
+
gem "minitest" # ensures you"re using the gem, and not the built-in MT
|
|
473
|
+
require "minitest/autorun"
|
|
424
474
|
|
|
425
475
|
# ... usual testing stuffs ...
|
|
426
476
|
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# -*- ruby -*-
|
|
2
2
|
|
|
3
|
-
$TESTING_MINIUNIT = true
|
|
4
|
-
|
|
5
3
|
require 'rubygems'
|
|
6
4
|
require 'hoe'
|
|
7
5
|
|
|
@@ -14,10 +12,6 @@ Hoe.spec 'minitest' do
|
|
|
14
12
|
self.testlib = :minitest
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
def loc dir
|
|
18
|
-
system "find #{dir} -name \\*.rb | xargs wc -l | tail -1"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
15
|
desc "Find missing expectations"
|
|
22
16
|
task :specs do
|
|
23
17
|
$:.unshift "lib"
|
|
@@ -38,8 +32,8 @@ task :specs do
|
|
|
38
32
|
/must_raises/ => 'must_raise',
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
expectations =
|
|
42
|
-
assertions =
|
|
35
|
+
expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
|
|
36
|
+
assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
|
|
43
37
|
|
|
44
38
|
assertions.sort.each do |assertion|
|
|
45
39
|
expectation = case assertion
|
|
@@ -63,32 +57,10 @@ task :specs do
|
|
|
63
57
|
puts
|
|
64
58
|
puts "##"
|
|
65
59
|
puts "# :method: #{expectation}"
|
|
66
|
-
puts "# See
|
|
60
|
+
puts "# See Minitest::Assertions##{assertion}"
|
|
67
61
|
puts
|
|
68
62
|
puts "infect_an_assertion #{args.join ", "}"
|
|
69
63
|
end
|
|
70
64
|
end
|
|
71
65
|
|
|
72
|
-
desc "stupid line count"
|
|
73
|
-
task :dickwag do
|
|
74
|
-
puts
|
|
75
|
-
puts "miniunit"
|
|
76
|
-
puts
|
|
77
|
-
print " lib loc"; loc "lib"
|
|
78
|
-
print " test loc"; loc "test"
|
|
79
|
-
print " totl loc"; loc "lib test"
|
|
80
|
-
print " flog = "; system "flog -s lib"
|
|
81
|
-
|
|
82
|
-
puts
|
|
83
|
-
puts "test/unit"
|
|
84
|
-
puts
|
|
85
|
-
Dir.chdir File.expand_path("~/Work/svn/ruby/ruby_1_8") do
|
|
86
|
-
print " lib loc"; loc "lib/test"
|
|
87
|
-
print " test loc"; loc "test/testunit"
|
|
88
|
-
print " totl loc"; loc "lib/test test/testunit"
|
|
89
|
-
print " flog = "; system "flog -s lib/test"
|
|
90
|
-
end
|
|
91
|
-
puts
|
|
92
|
-
end
|
|
93
|
-
|
|
94
66
|
# vim: syntax=Ruby
|
data/design_rationale.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Specs: # Equivalent Unit Tests:
|
|
2
2
|
###############################################################################
|
|
3
|
-
describe Thingy do # class TestThingy <
|
|
3
|
+
describe Thingy do # class TestThingy < Minitest::Test
|
|
4
4
|
before do # def setup
|
|
5
5
|
do_some_setup # super
|
|
6
6
|
end # do_some_setup
|
|
@@ -26,7 +26,7 @@ end # assert_equal 2, 2
|
|
|
26
26
|
###############################################################################
|
|
27
27
|
# The specs generate:
|
|
28
28
|
|
|
29
|
-
class ThingySpec <
|
|
29
|
+
class ThingySpec < Minitest::Spec
|
|
30
30
|
def setup
|
|
31
31
|
super
|
|
32
32
|
do_some_setup
|
data/lib/hoe/minitest.rb
CHANGED
|
@@ -5,18 +5,22 @@ end
|
|
|
5
5
|
|
|
6
6
|
module Hoe::Minitest
|
|
7
7
|
def initialize_minitest
|
|
8
|
+
dir = "../../minitest/dev/lib"
|
|
9
|
+
Hoe.add_include_dirs dir if File.directory? dir
|
|
10
|
+
|
|
8
11
|
gem "minitest"
|
|
9
|
-
require
|
|
10
|
-
version =
|
|
12
|
+
require "minitest"
|
|
13
|
+
version = Minitest::VERSION.split(/\./).first(2).join(".")
|
|
11
14
|
|
|
12
|
-
dependency
|
|
13
|
-
self.name == "minitest"
|
|
15
|
+
dependency "minitest", "~> #{version}", :development unless
|
|
16
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def define_minitest_tasks
|
|
17
20
|
self.testlib = :minitest
|
|
18
21
|
|
|
19
22
|
# make sure we use the gemmed minitest on 1.9
|
|
20
|
-
self.test_prelude = 'gem "minitest"'
|
|
23
|
+
self.test_prelude = 'gem "minitest"' unless
|
|
24
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
|
21
25
|
end
|
|
22
26
|
end
|