minitest 5.10.3 → 5.18.0
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +267 -4
- data/Manifest.txt +3 -0
- data/README.rdoc +123 -22
- data/Rakefile +5 -16
- data/lib/hoe/minitest.rb +0 -4
- data/lib/minitest/assertions.rb +197 -32
- data/lib/minitest/benchmark.rb +39 -8
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/mock.rb +118 -34
- data/lib/minitest/parallel.rb +1 -1
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/spec.rb +27 -9
- data/lib/minitest/test.rb +38 -66
- data/lib/minitest/test_task.rb +305 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +271 -52
- data/test/minitest/metametameta.rb +44 -9
- data/test/minitest/test_minitest_assertions.rb +1701 -0
- data/test/minitest/test_minitest_benchmark.rb +2 -2
- data/test/minitest/test_minitest_mock.rb +648 -14
- data/test/minitest/test_minitest_reporter.rb +46 -21
- data/test/minitest/test_minitest_spec.rb +317 -156
- data/test/minitest/test_minitest_test.rb +308 -1146
- data/test/minitest/test_minitest_test_task.rb +46 -0
- data.tar.gz.sig +1 -2
- metadata +36 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 27d1d24e16ba576cc5a425d6e09e3de81465d10104a647c21ad9a5df36be1551
|
4
|
+
data.tar.gz: c3ca5dd490b7d08ee3254c7c8a680af0675f72e5356ad97b55dd1ec67e27251d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f545c292aabb802ae8e03cea73bf2334a8ac6dea7da411b8e6ad48e036b00eabac550e5405c11aea175b30a9d65aced4e3601258081e845299ff6e1dbffd353d
|
7
|
+
data.tar.gz: ae62ac5c0f4218b66fe0206eb0205828c872531d6b68a4b0537fbe4b0a8753ccf604b4d11a11322dc329b275a1428683125c061e6e255f90ff5a076e4afb02ad
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,267 @@
|
|
1
|
+
=== 5.18.0 / 2023-03-04
|
2
|
+
|
3
|
+
* 2 major enhancements:
|
4
|
+
|
5
|
+
* Added assert_pattern & refute_pattern for pattern matching. (flavorjones)
|
6
|
+
* Added matching must_pattern_match & wont_pattern_match to minitest/spec.
|
7
|
+
|
8
|
+
* 1 bug fix:
|
9
|
+
|
10
|
+
* Support the new message format of NameError in Ruby 3.3 (mame)
|
11
|
+
|
12
|
+
=== 5.17.0 / 2022-12-31
|
13
|
+
|
14
|
+
* 1 minor enhancement:
|
15
|
+
|
16
|
+
* Refactor setup hooks into a SETUP_METHODS constant. (MSP-Greg)
|
17
|
+
|
18
|
+
* 3 bug fixes:
|
19
|
+
|
20
|
+
* Fix kwargs for Mock calls to delegator. (blowmage)
|
21
|
+
* Fix kwargs for expectations. (bobmazanec, blowmage)
|
22
|
+
* Remove check for .b method. (tenderlove)
|
23
|
+
|
24
|
+
=== 5.16.3 / 2022-08-17
|
25
|
+
|
26
|
+
* 2 bug fixes:
|
27
|
+
|
28
|
+
* Fixed exception sanitization by removing TypeError restriction on rescue.
|
29
|
+
* Use A instead of deprecated TESTOPTS in rake test:slow. (davidstosik)
|
30
|
+
|
31
|
+
=== 5.16.2 / 2022-07-03
|
32
|
+
|
33
|
+
* 4 bug fixes:
|
34
|
+
|
35
|
+
* Added MT_KWARGS_HACK kludge for stub to deal with ruby 2.7 kwargs nastiness. (tsugimoto)
|
36
|
+
* In #expect, pop Hash class from args if $MT_KWARGS_HACK. (casperisfine)
|
37
|
+
* In above scenario, set expected kwargs (as Objects) based on actual kwargs.
|
38
|
+
* Nuke ivars if exception fails to marshal twice (eg better_errors). (irphilli)
|
39
|
+
|
40
|
+
=== 5.16.1 / 2022-06-20
|
41
|
+
|
42
|
+
* 2 bug fixes:
|
43
|
+
|
44
|
+
* Apparently adding real kwarg support to mocks/stubs broke some code. Fixed.
|
45
|
+
* Use `MT_KWARGS_HACK=1` to activate the kludgy kwargs support w/ caveats.
|
46
|
+
* Clarified some doco wrt the block on #stub.
|
47
|
+
|
48
|
+
=== 5.16.0 / 2022-06-14
|
49
|
+
|
50
|
+
* 2 major enhancements:
|
51
|
+
|
52
|
+
* Added Minitest::TestTask.
|
53
|
+
* Dropping ruby 2.2 - 2.5. 2.6 is DTM soon too.
|
54
|
+
|
55
|
+
* 11 minor enhancements:
|
56
|
+
|
57
|
+
* Added --show-skips option to show skips at end of run but not require --verbose. (MSP-Greg)
|
58
|
+
* Added Minitest.seed, the random seed used by the run.
|
59
|
+
* Calling `srand Minitest.seed` before all shuffles to ensure determinism.
|
60
|
+
* Extended #stub to handle kwargs for both block and call args. (SampsonCrowley)
|
61
|
+
* Extended Mock#__call to display kwargs.
|
62
|
+
* Extended Mock#expect to record kwargs.
|
63
|
+
* Extended Mock#method_missing to take kwargs & compare them against expected.
|
64
|
+
* Mock#method_missing displays better errors on arity mismatch.
|
65
|
+
* Removed minor optimization removing empty suites before run.
|
66
|
+
* Simplified test randomization (test order will change even with fixed seed).
|
67
|
+
* assert_match now returns the MatchData on success. (Nakilon)
|
68
|
+
|
69
|
+
* 3 bug fixes:
|
70
|
+
|
71
|
+
* (Re)Fixed marshalling of exceptions, neutering them in 2 passes.
|
72
|
+
* Fixed more problems with rdoc.
|
73
|
+
* Had to patch up mock and stub to deal with <=2.7 kwargs oddities
|
74
|
+
|
75
|
+
=== 5.15.0 / 2021-12-14
|
76
|
+
|
77
|
+
* 1 major enhancement:
|
78
|
+
|
79
|
+
* assert_throws returns the value returned, if any. (volmer)
|
80
|
+
|
81
|
+
* 3 minor enhancements:
|
82
|
+
|
83
|
+
* Added -S <CODES> option to skip reporting of certain types of output
|
84
|
+
* Enable Ruby deprecation warnings by default. (casperisfine)
|
85
|
+
* Use Etc.nprocessors by default in order to maximize cpu usage. (tonytonyjan)
|
86
|
+
|
87
|
+
* 6 bug fixes:
|
88
|
+
|
89
|
+
* Close then unlink tempfiles on Windows. (nobu)
|
90
|
+
* Fixed #skip_until for windows paths. (MSP-Greg)
|
91
|
+
* Fixed a bunch of tests for jruby and windows. (MSP-Greg)
|
92
|
+
* Fixed marshalling of specs if they error. (tenderlove, jeremyevans, et al)
|
93
|
+
* Updated deprecation message for block expectations. (blowmage)
|
94
|
+
* Use Kernel.warn directly in expectations in case CUT defines their own warn. (firien)
|
95
|
+
|
96
|
+
=== 5.14.4 / 2021-02-23
|
97
|
+
|
98
|
+
* 1 bug fix:
|
99
|
+
|
100
|
+
* Fixed deprecation warning using stub with methods using keyword arguments. (Nakilon)
|
101
|
+
|
102
|
+
=== 5.14.3 / 2021-01-05
|
103
|
+
|
104
|
+
* 1 bug fix:
|
105
|
+
|
106
|
+
* Bumped require_ruby_version to < 4 (trunk = 3.1).
|
107
|
+
|
108
|
+
=== 5.14.2 / 2020-08-31
|
109
|
+
|
110
|
+
* 1 bug fix:
|
111
|
+
|
112
|
+
* Bumped ruby version to include 3.0 (trunk).
|
113
|
+
|
114
|
+
=== 5.14.1 / 2020-05-15
|
115
|
+
|
116
|
+
* 3 minor enhancements:
|
117
|
+
|
118
|
+
* Minitest.filter_backtrace returns original backtrace if filter comes back empty.
|
119
|
+
* Minitest::BacktraceFilter now returns entire backtrace if $MT_DEBUG set in env.
|
120
|
+
* Return true on a successful refute. (jusleg)
|
121
|
+
|
122
|
+
* 1 bug fix:
|
123
|
+
|
124
|
+
* Fixed expectation doco to not use global expectations.
|
125
|
+
|
126
|
+
=== 5.14.0 / 2020-01-11
|
127
|
+
|
128
|
+
* 2 minor enhancements:
|
129
|
+
|
130
|
+
* Block-assertions (eg assert_output) now error if raised inside the block. (casperisfine)
|
131
|
+
* Changed assert_raises to only catch Assertion since that covers Skip and friends.
|
132
|
+
|
133
|
+
* 3 bug fixes:
|
134
|
+
|
135
|
+
* Added example for value wrapper with block to Expectations module. (stomar)
|
136
|
+
* Fixed use of must/wont_be_within_delta on Expectation instance. (stomar)
|
137
|
+
* Renamed UnexpectedError#exception to #error to avoid problems with reraising. (casperisfine)
|
138
|
+
|
139
|
+
=== 5.13.0 / 2019-10-29
|
140
|
+
|
141
|
+
* 9 minor enhancements:
|
142
|
+
|
143
|
+
* Added Minitest::Guard#osx?
|
144
|
+
* Added examples to documentation for assert_raises. (lxxxvi)
|
145
|
+
* Added expectations #path_must_exist and #path_wont_exist. Not thrilled with the names.
|
146
|
+
* Added fail_after(year, month, day, msg) to allow time-bombing after a deadline.
|
147
|
+
* Added skip_until(year, month, day, msg) to allow deferring until a deadline.
|
148
|
+
* Deprecated Minitest::Guard#maglev?
|
149
|
+
* Deprecated Minitest::Guard#rubinius?
|
150
|
+
* Finally added assert_path_exists and refute_path_exists. (deivid-rodriguez)
|
151
|
+
* Refactored and pulled Assertions#things_to_diff out of #diff. (BurdetteLamar)
|
152
|
+
|
153
|
+
* 3 bug fixes:
|
154
|
+
|
155
|
+
* Fix autorun bug that affects fork exit status in tests. (dylanahsmith/jhawthorn)
|
156
|
+
* Improved documentation for _/value/expect, especially for blocks. (svoop)
|
157
|
+
* Support new Proc#to_s format. (ko1)
|
158
|
+
|
159
|
+
=== 5.12.2 / 2019-09-28
|
160
|
+
|
161
|
+
* 1 bug fix:
|
162
|
+
|
163
|
+
* After chatting w/ @y-yagi and others, decided to lower support to include ruby 2.2.
|
164
|
+
|
165
|
+
=== 5.12.1 / 2019-09-28
|
166
|
+
|
167
|
+
* 1 minor enhancement:
|
168
|
+
|
169
|
+
* Added documentation for Reporter classes. (sshaw)
|
170
|
+
|
171
|
+
* 3 bug fixes:
|
172
|
+
|
173
|
+
* Avoid using 'match?' to support older ruby versions. (y-yagi)
|
174
|
+
* Fixed broken link to reference on goodness-of-fit testing. (havenwood)
|
175
|
+
* Update requirements in readme and Rakefile/hoe spec.
|
176
|
+
|
177
|
+
=== 5.12.0 / 2019-09-22
|
178
|
+
|
179
|
+
* 8 minor enhancements:
|
180
|
+
|
181
|
+
* Added a descriptive error if assert_output or assert_raises called without a block. (okuramasafumi)
|
182
|
+
* Changed mu_pp_for_diff to make having both \n and \\n easier to debug.
|
183
|
+
* Deprecated $N for specifying number of parallel test runners. Use MT_CPU.
|
184
|
+
* Deprecated use of global expectations. To be removed from MT6.
|
185
|
+
* Extended Assertions#mu_pp to encoding validity output for strings to improve diffs.
|
186
|
+
* Extended Assertions#mu_pp to output encoding and validity if invalid to improve diffs.
|
187
|
+
* Extended Assertions#mu_pp_for_diff to make escaped newlines more obvious in diffs.
|
188
|
+
* Fail gracefully when expectation used outside of `it`.
|
189
|
+
|
190
|
+
* 3 bug fixes:
|
191
|
+
|
192
|
+
* Check `option[:filter]` klass before match. Fixes 2.6 warning. (y-yagi)
|
193
|
+
* Fixed Assertions#diff from recalculating if set to nil
|
194
|
+
* Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
|
195
|
+
|
196
|
+
=== 5.11.3 / 2018-01-26
|
197
|
+
|
198
|
+
* 1 bug fix:
|
199
|
+
|
200
|
+
* Pushed #error? up to Reportable module. (composerinteralia)
|
201
|
+
|
202
|
+
=== 5.11.2 / 2018-01-25
|
203
|
+
|
204
|
+
* 1 minor enhancement:
|
205
|
+
|
206
|
+
* Reversed Test < Result. Back to < Runnable and using Reportable for shared code.
|
207
|
+
|
208
|
+
* 2 bug fixes:
|
209
|
+
|
210
|
+
* Fixed Result#location for instances of Test. (alexisbernard)
|
211
|
+
* Fixed deprecation message for Runnable#marshal_dump. (y-yagi)
|
212
|
+
|
213
|
+
=== 5.11.1 / 2018-01-02
|
214
|
+
|
215
|
+
* 1 bug fix:
|
216
|
+
|
217
|
+
* Fixed Result (a superclass of Test) overriding Runnable's name accessors. (y-yagi, MSP-Greg)
|
218
|
+
|
219
|
+
=== 5.11.0 / 2018-01-01
|
220
|
+
|
221
|
+
* 2 major enhancements:
|
222
|
+
|
223
|
+
* Added Minitest::Result and Minitest::Result.from(runnable).
|
224
|
+
* Changed Minitest::Test to subclass Result and refactored methods up.
|
225
|
+
|
226
|
+
* 7 minor enhancements:
|
227
|
+
|
228
|
+
* Added --no-plugins and MT_NO_PLUGINS to bypass MT plugin autoloading. Helps with bad actors installed globally.
|
229
|
+
* Added bench_performance_{logarithmic,power} for spec-style benchmarks. (rickhull)
|
230
|
+
* Added deprecation warning for Runnable#marshal_dump.
|
231
|
+
* Minitest.run_one_method now checks for instance of Result, not exact same class.
|
232
|
+
* Minitest::Test.run returns a Result version of self, not self.
|
233
|
+
* ProgressReporter#prerecord now explicitly prints klass.name. Allows for fakers.
|
234
|
+
|
235
|
+
* 4 bug fixes:
|
236
|
+
|
237
|
+
* Object.stub no longer calls the passed block if stubbed with a callable.
|
238
|
+
* Object.stub now passes blocks down to the callable result.
|
239
|
+
* Pushed Minitest::Test#time & #time_it up to Runnable.
|
240
|
+
* Test nil equality directly in assert_equal. Fixes #679. (voxik)
|
241
|
+
|
242
|
+
=== 5.11.0b1 / 2017-12-20
|
243
|
+
|
244
|
+
* 2 major enhancements:
|
245
|
+
|
246
|
+
* Added Minitest::Result and Minitest::Result.from(runnable).
|
247
|
+
* Changed Minitest::Test to subclass Result and refactored methods up.
|
248
|
+
|
249
|
+
* 6 minor enhancements:
|
250
|
+
|
251
|
+
* Added --no-plugins and MT_NO_PLUGINS to bypass MT plugin autoloading. Helps with bad actors installed globally.
|
252
|
+
* Added bench_performance_{logarithmic,power} for spec-style benchmarks. (rickhull)
|
253
|
+
* Minitest.run_one_method now checks for instance of Result, not exact same class.
|
254
|
+
* Minitest::Test.run returns a Result version of self, not self.
|
255
|
+
* ProgressReporter#prerecord now explicitly prints klass.name. Allows for fakers.
|
256
|
+
* Removed Runnable.marshal_dump/load.
|
257
|
+
|
258
|
+
* 4 bug fixes:
|
259
|
+
|
260
|
+
* Object.stub no longer calls the passed block if stubbed with a callable.
|
261
|
+
* Object.stub now passes blocks down to the callable result.
|
262
|
+
* Pushed Minitest::Test#time & #time_it up to Runnable.
|
263
|
+
* Test nil equality directly in assert_equal. Fixes #679. (voxik)
|
264
|
+
|
1
265
|
=== 5.10.3 / 2017-07-21
|
2
266
|
|
3
267
|
* 1 minor enhancement:
|
@@ -54,7 +318,7 @@
|
|
54
318
|
* 2 bug fixes:
|
55
319
|
|
56
320
|
* Re-release to refresh gem certificate signing. ugh.
|
57
|
-
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
|
321
|
+
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
|
58
322
|
|
59
323
|
=== 5.9.0 / 2016-05-16
|
60
324
|
|
@@ -78,7 +342,7 @@
|
|
78
342
|
* 2 bug fixes:
|
79
343
|
|
80
344
|
* Re-release to refresh gem certificate signing. ugh.
|
81
|
-
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
|
345
|
+
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
|
82
346
|
|
83
347
|
=== 5.8.4 / 2016-01-21
|
84
348
|
|
@@ -392,7 +656,7 @@ Minitest 5:
|
|
392
656
|
* Added Minitest::Benchmark.
|
393
657
|
* Your benchmarks need to move to their own subclass.
|
394
658
|
* Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
|
395
|
-
* MiniTest::Unit.after_tests moved to Minitest.
|
659
|
+
* MiniTest::Unit.after_tests moved to Minitest.after_run
|
396
660
|
* MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
|
397
661
|
* Removed ParallelEach#grep since it isn't used anywhere.
|
398
662
|
* Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
|
@@ -1238,4 +1502,3 @@ back.
|
|
1238
1502
|
* 1 major enhancement
|
1239
1503
|
|
1240
1504
|
* Birthday!
|
1241
|
-
|
data/Manifest.txt
CHANGED
@@ -17,10 +17,13 @@ lib/minitest/pride.rb
|
|
17
17
|
lib/minitest/pride_plugin.rb
|
18
18
|
lib/minitest/spec.rb
|
19
19
|
lib/minitest/test.rb
|
20
|
+
lib/minitest/test_task.rb
|
20
21
|
lib/minitest/unit.rb
|
21
22
|
test/minitest/metametameta.rb
|
23
|
+
test/minitest/test_minitest_assertions.rb
|
22
24
|
test/minitest/test_minitest_benchmark.rb
|
23
25
|
test/minitest/test_minitest_mock.rb
|
24
26
|
test/minitest/test_minitest_reporter.rb
|
25
27
|
test/minitest/test_minitest_spec.rb
|
26
28
|
test/minitest/test_minitest_test.rb
|
29
|
+
test/minitest/test_minitest_test_task.rb
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
home :: https://github.com/seattlerb/minitest
|
4
4
|
bugs :: https://github.com/seattlerb/minitest/issues
|
5
|
-
rdoc ::
|
5
|
+
rdoc :: https://docs.seattlerb.org/minitest
|
6
6
|
vim :: https://github.com/sunaku/vim-ruby-minitest
|
7
7
|
emacs:: https://github.com/arthurnn/minitest-emacs
|
8
8
|
|
@@ -70,6 +70,7 @@ extract-method refactorings still apply.
|
|
70
70
|
* minitest/mock - a simple and clean mock/stub system.
|
71
71
|
* minitest/benchmark - an awesome way to assert your algorithm's performance.
|
72
72
|
* minitest/pride - show your pride in testing!
|
73
|
+
* minitest/test_task - a full-featured and clean rake task generator.
|
73
74
|
* Incredibly small and fast runner, but no bells and whistles.
|
74
75
|
* Written by squishy human beings. Software can never be perfect. We will all eventually die.
|
75
76
|
|
@@ -126,13 +127,13 @@ Define your tests as methods beginning with +test_+.
|
|
126
127
|
|
127
128
|
describe "when asked about cheeseburgers" do
|
128
129
|
it "must respond positively" do
|
129
|
-
@meme.i_can_has_cheezburger
|
130
|
+
_(@meme.i_can_has_cheezburger?).must_equal "OHAI!"
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
133
134
|
describe "when asked about blending possibilities" do
|
134
135
|
it "won't say no" do
|
135
|
-
@meme.will_it_blend
|
136
|
+
_(@meme.will_it_blend?).wont_match /^no/i
|
136
137
|
end
|
137
138
|
end
|
138
139
|
end
|
@@ -186,7 +187,7 @@ Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
186
187
|
=== Mocks
|
187
188
|
|
188
189
|
Mocks and stubs defined using terminology by Fowler & Meszaros at
|
189
|
-
|
190
|
+
https://www.martinfowler.com/bliki/TestDouble.html:
|
190
191
|
|
191
192
|
"Mocks are pre-programmed with expectations which form a specification
|
192
193
|
of the calls they are expected to receive. They can throw an exception
|
@@ -220,9 +221,9 @@ verification to ensure they got all the calls they were expecting."
|
|
220
221
|
end
|
221
222
|
end
|
222
223
|
|
223
|
-
|
224
|
+
==== Multi-threading and Mocks
|
224
225
|
|
225
|
-
Minitest mocks do not support multi-threading
|
226
|
+
Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
|
226
227
|
you can use regular ruby patterns and facilities like local variables. Here's
|
227
228
|
an example of asserting that code inside a thread is run:
|
228
229
|
|
@@ -237,7 +238,7 @@ an example of asserting that code inside a thread is run:
|
|
237
238
|
=== Stubs
|
238
239
|
|
239
240
|
Mocks and stubs are defined using terminology by Fowler & Meszaros at
|
240
|
-
|
241
|
+
https://www.martinfowler.com/bliki/TestDouble.html:
|
241
242
|
|
242
243
|
"Stubs provide canned answers to calls made during the test".
|
243
244
|
|
@@ -264,9 +265,8 @@ new non-existing method:
|
|
264
265
|
|
265
266
|
=== Running Your Tests
|
266
267
|
|
267
|
-
Ideally, you'll use a rake task to run your tests, either
|
268
|
-
all at once.
|
269
|
-
tests. BUT! You don't have to:
|
268
|
+
Ideally, you'll use a rake task to run your tests (see below), either
|
269
|
+
piecemeal or all at once. BUT! You don't have to:
|
270
270
|
|
271
271
|
% ruby -Ilib:test test/minitest/test_minitest_test.rb
|
272
272
|
Run options: --seed 37685
|
@@ -294,6 +294,45 @@ provided via plugins. To see them, simply run with +--help+:
|
|
294
294
|
-p, --pride Pride. Show your testing pride!
|
295
295
|
-a, --autotest Connect to autotest server.
|
296
296
|
|
297
|
+
=== Rake Tasks
|
298
|
+
|
299
|
+
You can set up a rake task to run all your tests by adding this to your Rakefile:
|
300
|
+
|
301
|
+
require "minitest/test_task"
|
302
|
+
|
303
|
+
Minitest::TestTask.create # named test, sensible defaults
|
304
|
+
|
305
|
+
# or more explicitly:
|
306
|
+
|
307
|
+
Minitest::TestTask.create(:test) do |t|
|
308
|
+
t.libs << "test"
|
309
|
+
t.libs << "lib"
|
310
|
+
t.warning = false
|
311
|
+
t.test_globs = ["test/**/*_test.rb"]
|
312
|
+
end
|
313
|
+
|
314
|
+
task :default => :test
|
315
|
+
|
316
|
+
Each of these will generate 4 tasks:
|
317
|
+
|
318
|
+
rake test :: Run the test suite.
|
319
|
+
rake test:cmd :: Print out the test command.
|
320
|
+
rake test:isolated :: Show which test files fail when run separately.
|
321
|
+
rake test:slow :: Show bottom 25 tests sorted by time.
|
322
|
+
|
323
|
+
=== Rake Task Variables
|
324
|
+
|
325
|
+
There are a bunch of variables you can supply to rake to modify the run.
|
326
|
+
|
327
|
+
MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
|
328
|
+
N :: -n: Tests to run (string or /regexp/).
|
329
|
+
X :: -x: Tests to exclude (string or /regexp/).
|
330
|
+
A :: Any extra arguments. Honors shell quoting.
|
331
|
+
MT_CPU :: How many threads to use for parallel test runs
|
332
|
+
SEED :: -s --seed Sets random seed.
|
333
|
+
TESTOPTS :: Deprecated, same as A
|
334
|
+
FILTER :: Deprecated, same as A
|
335
|
+
|
297
336
|
== Writing Extensions
|
298
337
|
|
299
338
|
To define a plugin, add a file named minitest/XXX_plugin.rb to your
|
@@ -364,6 +403,39 @@ Using our example above, here is how we might implement MyCI:
|
|
364
403
|
|
365
404
|
== FAQ
|
366
405
|
|
406
|
+
=== What versions are compatible with what? Or what versions are supported?
|
407
|
+
|
408
|
+
Minitest is a dependency of rails, which until fairly recently had an
|
409
|
+
overzealous backwards compatibility policy. As such, I'm stuck
|
410
|
+
supporting versions of ruby that are long past EOL. Hopefully I'll be
|
411
|
+
able to support only current versions of ruby sometime in the near
|
412
|
+
future.
|
413
|
+
|
414
|
+
(As of 2022-11-29)
|
415
|
+
|
416
|
+
Current versions of rails: (https://endoflife.date/rails)
|
417
|
+
|
418
|
+
| rails | min ruby | rec ruby | minitest | status | EOL Date |
|
419
|
+
|-------+----------+----------+----------+----------+------------|
|
420
|
+
| 7.0 | >= 2.7 | 3.1 | >= 5.1 | Current | 2025-06-01?|
|
421
|
+
| 6.1 | >= 2.5 | 3.0 | >= 5.1 | Maint | 2024-06-01?|
|
422
|
+
| 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
|
423
|
+
| 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | EOL | 2022-06-01 |
|
424
|
+
|
425
|
+
Current versions of ruby: (https://endoflife.date/ruby)
|
426
|
+
|
427
|
+
| ruby | Status | EOL Date |
|
428
|
+
|------+---------+------------|
|
429
|
+
| 3.1 | Current | 2025-12-25 |
|
430
|
+
| 3.0 | Maint | 2024-03-31 |
|
431
|
+
| 2.7 | Maint* | 2023-03-31 |
|
432
|
+
| 2.6 | EOL | 2022-03-31 |
|
433
|
+
| 2.5 | EOL | 2021-03-31 |
|
434
|
+
|
435
|
+
See also:
|
436
|
+
|
437
|
+
* https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
438
|
+
|
367
439
|
=== How to test SimpleDelegates?
|
368
440
|
|
369
441
|
The following implementation and test:
|
@@ -379,7 +451,7 @@ The following implementation and test:
|
|
379
451
|
end
|
380
452
|
|
381
453
|
it "must respond to work" do
|
382
|
-
@worker.must_respond_to :work
|
454
|
+
_(@worker).must_respond_to :work
|
383
455
|
end
|
384
456
|
end
|
385
457
|
|
@@ -434,11 +506,26 @@ you want to extend your test using setup/teardown via a module, just
|
|
434
506
|
make sure you ALWAYS call super. before/after automatically call super
|
435
507
|
for you, so make sure you don't do it twice.
|
436
508
|
|
509
|
+
=== How to run code before a group of tests?
|
510
|
+
|
511
|
+
Use a constant with begin...end like this:
|
512
|
+
|
513
|
+
describe Blah do
|
514
|
+
SETUP = begin
|
515
|
+
# ... this runs once when describe Blah starts
|
516
|
+
end
|
517
|
+
# ...
|
518
|
+
end
|
519
|
+
|
520
|
+
This can be useful for expensive initializations or sharing state.
|
521
|
+
Remember, this is just ruby code, so you need to make sure this
|
522
|
+
technique and sharing state doesn't interfere with your tests.
|
523
|
+
|
437
524
|
=== Why am I seeing <tt>uninitialized constant MiniTest::Test (NameError)</tt>?
|
438
525
|
|
439
|
-
Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
|
526
|
+
Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
|
440
527
|
in order to require minitest, you must first add the <tt>gem 'minitest'</tt>
|
441
|
-
to your Gemfile and run +bundle+. Once it's installed, you should be
|
528
|
+
to your Gemfile and run +bundle+. Once it's installed, you should be
|
442
529
|
able to require minitest and run your tests.
|
443
530
|
|
444
531
|
== Prominent Projects using Minitest:
|
@@ -454,6 +541,8 @@ able to require minitest and run your tests.
|
|
454
541
|
|
455
542
|
== Developing Minitest:
|
456
543
|
|
544
|
+
Minitest requires {Hoe}[https://rubygems.org/gems/hoe].
|
545
|
+
|
457
546
|
=== Minitest's own tests require UTF-8 external encoding.
|
458
547
|
|
459
548
|
This is a common problem in Windows, where the default external Encoding is
|
@@ -506,7 +595,7 @@ If you see failures like either of these, you are probably missing diff tool:
|
|
506
595
|
|
507
596
|
|
508
597
|
If you use Cygwin or MSYS2 or similar there are packages that include a
|
509
|
-
GNU diff for
|
598
|
+
GNU diff for Windows. If you don't, you can download GNU diffutils from
|
510
599
|
http://gnuwin32.sourceforge.net/packages/diffutils.htm
|
511
600
|
(make sure to add it to your PATH).
|
512
601
|
|
@@ -532,6 +621,7 @@ minispec-metadata :: Metadata for describe/it blocks & CLI tag filter.
|
|
532
621
|
E.g. <tt>it "requires JS driver", js: true do</tt> &
|
533
622
|
<tt>ruby test.rb --tag js</tt> runs tests tagged :js.
|
534
623
|
minispec-rails :: Minimal support to use Spec style in Rails 5+.
|
624
|
+
mini-apivore :: for swagger based automated API testing.
|
535
625
|
minitest-around :: Around block for minitest. An alternative to
|
536
626
|
setup/teardown dance.
|
537
627
|
minitest-assert_errors :: Adds Minitest assertions to test for errors raised
|
@@ -548,6 +638,7 @@ minitest-capistrano :: Assertions and expectations for testing
|
|
548
638
|
Capistrano recipes.
|
549
639
|
minitest-capybara :: Capybara matchers support for minitest unit and
|
550
640
|
spec.
|
641
|
+
minitest-cc :: It provides minimal information about code coverage.
|
551
642
|
minitest-chef-handler :: Run Minitest suites as Chef report handlers
|
552
643
|
minitest-ci :: CI reporter plugin for Minitest.
|
553
644
|
minitest-context :: Defines contexts for code reuse in Minitest
|
@@ -574,12 +665,14 @@ minitest-firemock :: Makes your Minitest mocks more resilient.
|
|
574
665
|
minitest-focus :: Focus on one test at a time.
|
575
666
|
minitest-gcstats :: A minitest plugin that adds a report of the top
|
576
667
|
tests by number of objects allocated.
|
668
|
+
minitest-global_expectations:: Support minitest expectation methods for all objects
|
577
669
|
minitest-great_expectations :: Generally useful additions to minitest's
|
578
670
|
assertions and expectations.
|
579
671
|
minitest-growl :: Test notifier for minitest via growl.
|
580
672
|
minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
|
581
|
-
minitest-have_tag :: Adds Minitest assertions to test for the existence of
|
673
|
+
minitest-have_tag :: Adds Minitest assertions to test for the existence of
|
582
674
|
HTML tags, including contents, within a provided string.
|
675
|
+
minitest-heat :: Reporting that builds a heat map of failure locations
|
583
676
|
minitest-hooks :: Around and before_all/after_all/around_all hooks
|
584
677
|
minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
|
585
678
|
minitest-implicit-subject :: Implicit declaration of the test subject.
|
@@ -588,6 +681,7 @@ minitest-instrument :: Instrument ActiveSupport::Notifications when
|
|
588
681
|
minitest-instrument-db :: Store information about speed of test execution
|
589
682
|
provided by minitest-instrument in database.
|
590
683
|
minitest-junit :: JUnit-style XML reporter for minitest.
|
684
|
+
minitest-keyword :: Use Minitest assertions with keyword arguments.
|
591
685
|
minitest-libnotify :: Test notifier for minitest via libnotify.
|
592
686
|
minitest-line :: Run test at line number.
|
593
687
|
minitest-logger :: Define assert_log and enable minitest to test log messages.
|
@@ -599,6 +693,7 @@ minitest-matchers :: Adds support for RSpec-style matchers to
|
|
599
693
|
minitest-matchers_vaccine :: Adds assertions that adhere to the matcher spec,
|
600
694
|
but without any expectation infections.
|
601
695
|
minitest-metadata :: Annotate tests with metadata (key-value).
|
696
|
+
minitest-mock_expectations :: Provides method call assertions for minitest.
|
602
697
|
minitest-mongoid :: Mongoid assertion matchers for Minitest.
|
603
698
|
minitest-must_not :: Provides must_not as an alias for wont in
|
604
699
|
Minitest.
|
@@ -614,10 +709,10 @@ minitest-rails-capybara :: Capybara integration for Minitest::Rails.
|
|
614
709
|
minitest-reporters :: Create customizable Minitest output formats.
|
615
710
|
minitest-rg :: Colored red/green output for Minitest.
|
616
711
|
minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
|
617
|
-
minitest-server :: minitest-server provides a client/server setup
|
618
|
-
with your minitest process, allowing your test
|
712
|
+
minitest-server :: minitest-server provides a client/server setup
|
713
|
+
with your minitest process, allowing your test
|
619
714
|
run to send its results directly to a handler.
|
620
|
-
minitest-sequel :: Minitest assertions to speed-up development and
|
715
|
+
minitest-sequel :: Minitest assertions to speed-up development and
|
621
716
|
testing of Ruby Sequel database setups.
|
622
717
|
minitest-shared_description :: Support for shared specs and shared spec
|
623
718
|
subclasses
|
@@ -642,16 +737,23 @@ minitest-stub-const :: Stub constants for the duration of a block.
|
|
642
737
|
minitest-tags :: Add tags for minitest.
|
643
738
|
minitest-unordered :: Adds a new assertion to minitest for checking the
|
644
739
|
contents of a collection, ignoring element order.
|
645
|
-
minitest-vcr :: Automatic cassette
|
740
|
+
minitest-vcr :: Automatic cassette management with Minitest::Spec
|
646
741
|
and VCR.
|
742
|
+
minitest_log :: Adds structured logging, data explication, and verdicts.
|
647
743
|
minitest_owrapper :: Get tests results as a TestResult object.
|
648
744
|
minitest_should :: Shoulda style syntax for minitest test::unit.
|
649
745
|
minitest_tu_shim :: Bridges between test/unit and minitest.
|
650
746
|
mongoid-minitest :: Minitest matchers for Mongoid.
|
747
|
+
mutant-minitest :: Minitest integration for mutant.
|
651
748
|
pry-rescue :: A pry plugin w/ minitest support. See
|
652
749
|
pry-rescue/minitest.rb.
|
750
|
+
rematch :: Declutter your test files from large hardcoded data
|
751
|
+
and update them automatically when your code changes.
|
653
752
|
rspec2minitest :: Easily translate any RSpec matchers to Minitest
|
654
753
|
assertions and expectations.
|
754
|
+
stubberry :: Multiple stubbing 'berries', sweet and useful
|
755
|
+
stub helpers and assertions. ( stub_must,
|
756
|
+
assert_method_called, stubbing ORM objects by id )
|
655
757
|
|
656
758
|
== Unknown Extensions:
|
657
759
|
|
@@ -677,12 +779,11 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
677
779
|
|
678
780
|
== Minitest related goods
|
679
781
|
|
680
|
-
* minitest/pride fabric:
|
782
|
+
* minitest/pride fabric: https://www.spoonflower.com/fabric/3928730-again-by-katie_allen
|
681
783
|
|
682
784
|
== REQUIREMENTS:
|
683
785
|
|
684
|
-
* Ruby
|
685
|
-
* NOTE: 1.8 and 1.9 will be dropped in minitest 6+.
|
786
|
+
* Ruby 2.3+. No magic is involved. I hope.
|
686
787
|
|
687
788
|
== INSTALL:
|
688
789
|
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rubygems"
|
4
4
|
require "hoe"
|
5
|
+
$:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
|
5
6
|
|
6
7
|
Hoe.plugin :seattlerb
|
7
8
|
Hoe.plugin :rdoc
|
@@ -11,21 +12,7 @@ Hoe.spec "minitest" do
|
|
11
12
|
|
12
13
|
license "MIT"
|
13
14
|
|
14
|
-
|
15
|
-
#
|
16
|
-
# self.post_install_message = <<-"EOM"
|
17
|
-
# NOTE: minitest 5 will be the last in the minitest family to support
|
18
|
-
# ruby 1.8 and 1.9 (and maybe 2.0?). If you need to keep using 1.8
|
19
|
-
# or 1.9, you need to pin your dependency to minitest with
|
20
|
-
# something like "~> 5.0".
|
21
|
-
#
|
22
|
-
# Further, minitest 6 will be dropping the following:
|
23
|
-
#
|
24
|
-
# + MiniTest (it's been Minitest for *years*)
|
25
|
-
# + MiniTest::Unit
|
26
|
-
# + MiniTest::Unit::TestCase
|
27
|
-
# + assert_send (unless you argue for it well)
|
28
|
-
# EOM
|
15
|
+
require_ruby_version [">= 2.6", "< 4.0"]
|
29
16
|
end
|
30
17
|
|
31
18
|
desc "Find missing expectations"
|
@@ -35,7 +22,7 @@ task :specs do
|
|
35
22
|
require "minitest/spec"
|
36
23
|
|
37
24
|
pos_prefix, neg_prefix = "must", "wont"
|
38
|
-
skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
|
25
|
+
skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|send|raise$)/x
|
39
26
|
dont_flip_re = /(must|wont)_(include|respond_to)/
|
40
27
|
|
41
28
|
map = {
|
@@ -46,6 +33,8 @@ task :specs do
|
|
46
33
|
/_includes/ => "_include",
|
47
34
|
/(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
|
48
35
|
/must_raises/ => "must_raise",
|
36
|
+
/(must|wont)_predicate/ => '\1_be',
|
37
|
+
/(must|wont)_path_exists/ => 'path_\1_exist',
|
49
38
|
}
|
50
39
|
|
51
40
|
expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
|