minitest 5.11.3 → 5.25.5
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +384 -4
- data/Manifest.txt +6 -0
- data/README.rdoc +113 -17
- data/Rakefile +11 -16
- data/lib/hoe/minitest.rb +2 -5
- data/lib/minitest/assertions.rb +255 -93
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +13 -16
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +151 -44
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +17 -24
- data/lib/minitest/spec.rb +38 -19
- data/lib/minitest/test.rb +51 -34
- data/lib/minitest/test_task.rb +307 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +414 -166
- data/test/minitest/metametameta.rb +65 -17
- data/test/minitest/test_minitest_assertions.rb +1720 -0
- data/test/minitest/test_minitest_benchmark.rb +3 -3
- data/test/minitest/test_minitest_mock.rb +409 -65
- data/test/minitest/test_minitest_reporter.rb +169 -32
- data/test/minitest/test_minitest_spec.rb +369 -193
- data/test/minitest/test_minitest_test.rb +479 -1247
- data/test/minitest/test_minitest_test_task.rb +57 -0
- data.tar.gz.sig +0 -0
- metadata +37 -23
- metadata.gz.sig +0 -0
data/README.rdoc
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
= minitest/{test,spec,mock,benchmark}
|
|
2
2
|
|
|
3
|
-
home :: https://github.com/
|
|
4
|
-
bugs :: https://github.com/
|
|
5
|
-
rdoc ::
|
|
3
|
+
home :: https://github.com/minitest/minitest
|
|
4
|
+
bugs :: https://github.com/minitest/minitest/issues
|
|
5
|
+
rdoc :: https://docs.seattlerb.org/minitest
|
|
6
|
+
clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
|
|
6
7
|
vim :: https://github.com/sunaku/vim-ruby-minitest
|
|
7
8
|
emacs:: https://github.com/arthurnn/minitest-emacs
|
|
8
9
|
|
|
@@ -70,6 +71,7 @@ extract-method refactorings still apply.
|
|
|
70
71
|
* minitest/mock - a simple and clean mock/stub system.
|
|
71
72
|
* minitest/benchmark - an awesome way to assert your algorithm's performance.
|
|
72
73
|
* minitest/pride - show your pride in testing!
|
|
74
|
+
* minitest/test_task - a full-featured and clean rake task generator.
|
|
73
75
|
* Incredibly small and fast runner, but no bells and whistles.
|
|
74
76
|
* Written by squishy human beings. Software can never be perfect. We will all eventually die.
|
|
75
77
|
|
|
@@ -126,13 +128,13 @@ Define your tests as methods beginning with +test_+.
|
|
|
126
128
|
|
|
127
129
|
describe "when asked about cheeseburgers" do
|
|
128
130
|
it "must respond positively" do
|
|
129
|
-
@meme.i_can_has_cheezburger
|
|
131
|
+
_(@meme.i_can_has_cheezburger?).must_equal "OHAI!"
|
|
130
132
|
end
|
|
131
133
|
end
|
|
132
134
|
|
|
133
135
|
describe "when asked about blending possibilities" do
|
|
134
136
|
it "won't say no" do
|
|
135
|
-
@meme.will_it_blend
|
|
137
|
+
_(@meme.will_it_blend?).wont_match /^no/i
|
|
136
138
|
end
|
|
137
139
|
end
|
|
138
140
|
end
|
|
@@ -186,7 +188,7 @@ Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
|
186
188
|
=== Mocks
|
|
187
189
|
|
|
188
190
|
Mocks and stubs defined using terminology by Fowler & Meszaros at
|
|
189
|
-
|
|
191
|
+
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
190
192
|
|
|
191
193
|
"Mocks are pre-programmed with expectations which form a specification
|
|
192
194
|
of the calls they are expected to receive. They can throw an exception
|
|
@@ -220,9 +222,9 @@ verification to ensure they got all the calls they were expecting."
|
|
|
220
222
|
end
|
|
221
223
|
end
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
==== Multi-threading and Mocks
|
|
224
226
|
|
|
225
|
-
Minitest mocks do not support multi-threading
|
|
227
|
+
Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
|
|
226
228
|
you can use regular ruby patterns and facilities like local variables. Here's
|
|
227
229
|
an example of asserting that code inside a thread is run:
|
|
228
230
|
|
|
@@ -237,7 +239,7 @@ an example of asserting that code inside a thread is run:
|
|
|
237
239
|
=== Stubs
|
|
238
240
|
|
|
239
241
|
Mocks and stubs are defined using terminology by Fowler & Meszaros at
|
|
240
|
-
|
|
242
|
+
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
241
243
|
|
|
242
244
|
"Stubs provide canned answers to calls made during the test".
|
|
243
245
|
|
|
@@ -264,9 +266,8 @@ new non-existing method:
|
|
|
264
266
|
|
|
265
267
|
=== Running Your Tests
|
|
266
268
|
|
|
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:
|
|
269
|
+
Ideally, you'll use a rake task to run your tests (see below), either
|
|
270
|
+
piecemeal or all at once. BUT! You don't have to:
|
|
270
271
|
|
|
271
272
|
% ruby -Ilib:test test/minitest/test_minitest_test.rb
|
|
272
273
|
Run options: --seed 37685
|
|
@@ -294,6 +295,45 @@ provided via plugins. To see them, simply run with +--help+:
|
|
|
294
295
|
-p, --pride Pride. Show your testing pride!
|
|
295
296
|
-a, --autotest Connect to autotest server.
|
|
296
297
|
|
|
298
|
+
=== Rake Tasks
|
|
299
|
+
|
|
300
|
+
You can set up a rake task to run all your tests by adding this to your Rakefile:
|
|
301
|
+
|
|
302
|
+
require "minitest/test_task"
|
|
303
|
+
|
|
304
|
+
Minitest::TestTask.create # named test, sensible defaults
|
|
305
|
+
|
|
306
|
+
# or more explicitly:
|
|
307
|
+
|
|
308
|
+
Minitest::TestTask.create(:test) do |t|
|
|
309
|
+
t.libs << "test"
|
|
310
|
+
t.libs << "lib"
|
|
311
|
+
t.warning = false
|
|
312
|
+
t.test_globs = ["test/**/*_test.rb"]
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
task :default => :test
|
|
316
|
+
|
|
317
|
+
Each of these will generate 4 tasks:
|
|
318
|
+
|
|
319
|
+
rake test :: Run the test suite.
|
|
320
|
+
rake test:cmd :: Print out the test command.
|
|
321
|
+
rake test:isolated :: Show which test files fail when run separately.
|
|
322
|
+
rake test:slow :: Show bottom 25 tests sorted by time.
|
|
323
|
+
|
|
324
|
+
=== Rake Task Variables
|
|
325
|
+
|
|
326
|
+
There are a bunch of variables you can supply to rake to modify the run.
|
|
327
|
+
|
|
328
|
+
MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
|
|
329
|
+
N :: -n: Tests to run (string or /regexp/).
|
|
330
|
+
X :: -x: Tests to exclude (string or /regexp/).
|
|
331
|
+
A :: Any extra arguments. Honors shell quoting.
|
|
332
|
+
MT_CPU :: How many threads to use for parallel test runs
|
|
333
|
+
SEED :: -s --seed Sets random seed.
|
|
334
|
+
TESTOPTS :: Deprecated, same as A
|
|
335
|
+
FILTER :: Deprecated, same as A
|
|
336
|
+
|
|
297
337
|
== Writing Extensions
|
|
298
338
|
|
|
299
339
|
To define a plugin, add a file named minitest/XXX_plugin.rb to your
|
|
@@ -364,6 +404,49 @@ Using our example above, here is how we might implement MyCI:
|
|
|
364
404
|
|
|
365
405
|
== FAQ
|
|
366
406
|
|
|
407
|
+
=== What versions are compatible with what? Or what versions are supported?
|
|
408
|
+
|
|
409
|
+
Minitest is a dependency of rails, which until very recently had an
|
|
410
|
+
overzealous backwards compatibility policy. As such, I'm stuck
|
|
411
|
+
supporting versions of ruby that are long past EOL. Hopefully I'll be
|
|
412
|
+
able to support only current versions of ruby sometime in the near
|
|
413
|
+
future.
|
|
414
|
+
|
|
415
|
+
NOTICE: At this point, I will only locally test/dev against the
|
|
416
|
+
currently 3 supported (non-EOL) versions of ruby. I cannot and will
|
|
417
|
+
not maintain that many builds.
|
|
418
|
+
|
|
419
|
+
(As of 2025-02-03)
|
|
420
|
+
|
|
421
|
+
Current versions of rails: (https://endoflife.date/rails)
|
|
422
|
+
|
|
423
|
+
| rails | min ruby | minitest | status | EOL Date |
|
|
424
|
+
|-------+----------+----------+----------+------------|
|
|
425
|
+
| 8.0 | >= 3.2 | >= 5.1 | Current | 2026-11-07 |
|
|
426
|
+
| 7.2 | >= 3.1 | >= 5.1 | Current | 2026-08-09 |
|
|
427
|
+
| 7.1 | >= 2.7 | >= 5.1 | Security | 2025-10-01 |
|
|
428
|
+
| 7.0 | >= 2.7 | >= 5.1 | Security | 2025-04-01 |
|
|
429
|
+
| 6.1 | >= 2.5 | >= 5.1 | EOL | 2024-10-01 |
|
|
430
|
+
| 6.0 | >= 2.5 | >= 5.1 | EOL | 2023-06-01 |
|
|
431
|
+
| 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
|
|
432
|
+
|
|
433
|
+
If you want to look at the requirements for a specific version, run:
|
|
434
|
+
|
|
435
|
+
gem spec -r --ruby rails -v 8.0.0
|
|
436
|
+
|
|
437
|
+
Current versions of ruby: (https://endoflife.date/ruby)
|
|
438
|
+
|
|
439
|
+
| ruby | Status | EOL Date |
|
|
440
|
+
|------+---------+------------|
|
|
441
|
+
| 3.4 | Current | 2028-03-31 |
|
|
442
|
+
| 3.3 | Maint | 2027-03-31 |
|
|
443
|
+
| 3.2 | Security| 2026-03-31 |
|
|
444
|
+
| 3.1 | EOL | 2025-03-31 |
|
|
445
|
+
| 3.0 | EOL | 2024-03-31 |
|
|
446
|
+
| 2.7 | EOL | 2023-03-31 |
|
|
447
|
+
| 2.6 | EOL | 2022-03-31 |
|
|
448
|
+
| 2.5 | EOL | 2021-03-31 |
|
|
449
|
+
|
|
367
450
|
=== How to test SimpleDelegates?
|
|
368
451
|
|
|
369
452
|
The following implementation and test:
|
|
@@ -379,7 +462,7 @@ The following implementation and test:
|
|
|
379
462
|
end
|
|
380
463
|
|
|
381
464
|
it "must respond to work" do
|
|
382
|
-
@worker.must_respond_to :work
|
|
465
|
+
_(@worker).must_respond_to :work
|
|
383
466
|
end
|
|
384
467
|
end
|
|
385
468
|
|
|
@@ -469,6 +552,8 @@ able to require minitest and run your tests.
|
|
|
469
552
|
|
|
470
553
|
== Developing Minitest:
|
|
471
554
|
|
|
555
|
+
Minitest requires {Hoe}[https://rubygems.org/gems/hoe].
|
|
556
|
+
|
|
472
557
|
=== Minitest's own tests require UTF-8 external encoding.
|
|
473
558
|
|
|
474
559
|
This is a common problem in Windows, where the default external Encoding is
|
|
@@ -547,6 +632,7 @@ minispec-metadata :: Metadata for describe/it blocks & CLI tag filter.
|
|
|
547
632
|
E.g. <tt>it "requires JS driver", js: true do</tt> &
|
|
548
633
|
<tt>ruby test.rb --tag js</tt> runs tests tagged :js.
|
|
549
634
|
minispec-rails :: Minimal support to use Spec style in Rails 5+.
|
|
635
|
+
mini-apivore :: for swagger based automated API testing.
|
|
550
636
|
minitest-around :: Around block for minitest. An alternative to
|
|
551
637
|
setup/teardown dance.
|
|
552
638
|
minitest-assert_errors :: Adds Minitest assertions to test for errors raised
|
|
@@ -563,6 +649,7 @@ minitest-capistrano :: Assertions and expectations for testing
|
|
|
563
649
|
Capistrano recipes.
|
|
564
650
|
minitest-capybara :: Capybara matchers support for minitest unit and
|
|
565
651
|
spec.
|
|
652
|
+
minitest-cc :: It provides minimal information about code coverage.
|
|
566
653
|
minitest-chef-handler :: Run Minitest suites as Chef report handlers
|
|
567
654
|
minitest-ci :: CI reporter plugin for Minitest.
|
|
568
655
|
minitest-context :: Defines contexts for code reuse in Minitest
|
|
@@ -589,12 +676,14 @@ minitest-firemock :: Makes your Minitest mocks more resilient.
|
|
|
589
676
|
minitest-focus :: Focus on one test at a time.
|
|
590
677
|
minitest-gcstats :: A minitest plugin that adds a report of the top
|
|
591
678
|
tests by number of objects allocated.
|
|
679
|
+
minitest-global_expectations:: Support minitest expectation methods for all objects
|
|
592
680
|
minitest-great_expectations :: Generally useful additions to minitest's
|
|
593
681
|
assertions and expectations.
|
|
594
682
|
minitest-growl :: Test notifier for minitest via growl.
|
|
595
683
|
minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
|
|
596
684
|
minitest-have_tag :: Adds Minitest assertions to test for the existence of
|
|
597
685
|
HTML tags, including contents, within a provided string.
|
|
686
|
+
minitest-heat :: Reporting that builds a heat map of failure locations
|
|
598
687
|
minitest-hooks :: Around and before_all/after_all/around_all hooks
|
|
599
688
|
minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
|
|
600
689
|
minitest-implicit-subject :: Implicit declaration of the test subject.
|
|
@@ -615,6 +704,7 @@ minitest-matchers :: Adds support for RSpec-style matchers to
|
|
|
615
704
|
minitest-matchers_vaccine :: Adds assertions that adhere to the matcher spec,
|
|
616
705
|
but without any expectation infections.
|
|
617
706
|
minitest-metadata :: Annotate tests with metadata (key-value).
|
|
707
|
+
minitest-mock_expectations :: Provides method call assertions for minitest.
|
|
618
708
|
minitest-mongoid :: Mongoid assertion matchers for Minitest.
|
|
619
709
|
minitest-must_not :: Provides must_not as an alias for wont in
|
|
620
710
|
Minitest.
|
|
@@ -658,16 +748,23 @@ minitest-stub-const :: Stub constants for the duration of a block.
|
|
|
658
748
|
minitest-tags :: Add tags for minitest.
|
|
659
749
|
minitest-unordered :: Adds a new assertion to minitest for checking the
|
|
660
750
|
contents of a collection, ignoring element order.
|
|
661
|
-
minitest-vcr :: Automatic cassette
|
|
751
|
+
minitest-vcr :: Automatic cassette management with Minitest::Spec
|
|
662
752
|
and VCR.
|
|
753
|
+
minitest_log :: Adds structured logging, data explication, and verdicts.
|
|
663
754
|
minitest_owrapper :: Get tests results as a TestResult object.
|
|
664
755
|
minitest_should :: Shoulda style syntax for minitest test::unit.
|
|
665
756
|
minitest_tu_shim :: Bridges between test/unit and minitest.
|
|
666
757
|
mongoid-minitest :: Minitest matchers for Mongoid.
|
|
758
|
+
mutant-minitest :: Minitest integration for mutant.
|
|
667
759
|
pry-rescue :: A pry plugin w/ minitest support. See
|
|
668
760
|
pry-rescue/minitest.rb.
|
|
761
|
+
rematch :: Declutter your test files from large hardcoded data
|
|
762
|
+
and update them automatically when your code changes.
|
|
669
763
|
rspec2minitest :: Easily translate any RSpec matchers to Minitest
|
|
670
764
|
assertions and expectations.
|
|
765
|
+
stubberry :: Multiple stubbing 'berries', sweet and useful
|
|
766
|
+
stub helpers and assertions. ( stub_must,
|
|
767
|
+
assert_method_called, stubbing ORM objects by id )
|
|
671
768
|
|
|
672
769
|
== Unknown Extensions:
|
|
673
770
|
|
|
@@ -693,12 +790,11 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
|
693
790
|
|
|
694
791
|
== Minitest related goods
|
|
695
792
|
|
|
696
|
-
* minitest/pride fabric:
|
|
793
|
+
* minitest/pride fabric: https://www.spoonflower.com/fabric/3928730-again-by-katie_allen
|
|
697
794
|
|
|
698
795
|
== REQUIREMENTS:
|
|
699
796
|
|
|
700
|
-
* Ruby
|
|
701
|
-
* NOTE: 1.8 and 1.9 will be dropped in minitest 6+.
|
|
797
|
+
* Ruby 2.3+. No magic is involved. I hope.
|
|
702
798
|
|
|
703
799
|
== INSTALL:
|
|
704
800
|
|
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.7", "< 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,9 @@ 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)_pattern/ => '\1_pattern_match',
|
|
37
|
+
/(must|wont)_predicate/ => '\1_be',
|
|
38
|
+
/(must|wont)_path_exists/ => 'path_\1_exist',
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
|
|
@@ -83,4 +73,9 @@ task :bugs do
|
|
|
83
73
|
sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
|
|
84
74
|
end
|
|
85
75
|
|
|
76
|
+
Minitest::TestTask.create :testW0 do |t|
|
|
77
|
+
t.warning = false
|
|
78
|
+
t.test_prelude = "$-w = nil"
|
|
79
|
+
end
|
|
80
|
+
|
|
86
81
|
# vim: syntax=Ruby
|
data/lib/hoe/minitest.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# :stopdoc:
|
|
2
2
|
|
|
3
3
|
class Hoe
|
|
4
|
+
# empty
|
|
4
5
|
end
|
|
5
6
|
|
|
6
7
|
module Hoe::Minitest
|
|
@@ -16,7 +17,7 @@ module Hoe::Minitest
|
|
|
16
17
|
|
|
17
18
|
gem "minitest"
|
|
18
19
|
require "minitest"
|
|
19
|
-
version = Minitest::VERSION.split(
|
|
20
|
+
version = Minitest::VERSION.split(".").first(2).join "."
|
|
20
21
|
|
|
21
22
|
dependency "minitest", "~> #{version}", :development unless
|
|
22
23
|
minitest? or ENV["MT_NO_ISOLATE"]
|
|
@@ -24,9 +25,5 @@ module Hoe::Minitest
|
|
|
24
25
|
|
|
25
26
|
def define_minitest_tasks
|
|
26
27
|
self.testlib = :minitest
|
|
27
|
-
|
|
28
|
-
# make sure we use the gemmed minitest on 1.9
|
|
29
|
-
self.test_prelude = 'gem "minitest"' unless
|
|
30
|
-
minitest? or ENV["MT_NO_ISOLATE"]
|
|
31
28
|
end
|
|
32
29
|
end
|