minitap 0.5.3 → 0.6.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
- data/HISTORY.md +41 -0
- data/README.md +82 -80
- data/demo/01_tapy.md +100 -0
- data/demo/02_tapj.md +32 -0
- data/demo/03_spec.md +45 -0
- data/demo/04_helper.md +109 -0
- data/demo/05_details.md +127 -0
- data/demo/06_tapout.md +44 -0
- data/demo/applique/ae.rb +1 -0
- data/demo/applique/run.rb +48 -0
- data/lib/minitap/autorun.rb +4 -5
- data/lib/minitap/reporter.rb +294 -0
- data/lib/minitap/version.rb +3 -0
- data/lib/minitap.rb +87 -7
- data/lib/minitest/minitap_plugin.rb +11 -31
- metadata +70 -58
- data/.index +0 -66
- data/DEMO.md +0 -95
- data/lib/minitap/ignore_callers.rb +0 -5
- data/lib/minitap/minitest5.rb +0 -885
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7b4b454f6ede5ceeeff5789c636220b737520b7d686aab23cd823ef64c08925b
|
|
4
|
+
data.tar.gz: dd115e163b1c544f23c562d0a5c1ca1c55d02a26a8dc66bd559dfdff917a9a6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d4c6e5390a6f0aa4c4be47a7a6ae459580829b9b27b378ef8c01f71ff780b46a13fc0c29ee0787c4398fc15baacfb3a5ede93f42cb4d3d6aab1fc63777c8eb4
|
|
7
|
+
data.tar.gz: b828ea048624d2df500eb13e0361cd0c97e733b7e5a9da61d8041fe8948983b6446fa3b1548435849c6021613617475de9b547b12bd35befe9af34da8c5beaa5
|
data/HISTORY.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# RELEASE HISTORY
|
|
2
2
|
|
|
3
|
+
## 0.6.0 | 2026-11-21
|
|
4
|
+
|
|
5
|
+
Minitap works with current Minitest again, including Minitest 6, and is
|
|
6
|
+
now a plain Minitest plugin. It needs Minitest 5.11 or newer and Ruby
|
|
7
|
+
2.7 or newer.
|
|
8
|
+
|
|
9
|
+
Changes:
|
|
10
|
+
|
|
11
|
+
* Work with Minitest 6. The dependency was `~> 5.0`, so Minitap couldn't
|
|
12
|
+
be installed alongside it.
|
|
13
|
+
* Use Minitest's plugin system only. Minitap registers itself as a plugin
|
|
14
|
+
when it is required, and no longer depends on `minitest-reporter-api`,
|
|
15
|
+
which replaced `Minitest.run` with a copy from 2013.
|
|
16
|
+
* Choose the format in code with `Minitap.tapy!`, `Minitap.tapj!` or
|
|
17
|
+
`Minitap.format = :tapy`. `Minitest.reporter = Minitap::TapY` no longer
|
|
18
|
+
does anything.
|
|
19
|
+
* `require 'minitap/autorun'` works again. It printed nothing and exited
|
|
20
|
+
with an error.
|
|
21
|
+
* Label a case with the name of its test class. With Minitest 5.11 and
|
|
22
|
+
newer every case was labelled `Minitest::Result`.
|
|
23
|
+
* Give the location of a failure in the test file. On Ruby 3.4 and newer
|
|
24
|
+
it was given as a line in Minitest's own `assertions.rb`.
|
|
25
|
+
* Report a skipped test with the status `omit`, which is what TAP-Y/J
|
|
26
|
+
specifies. It was `skip`, which Tapout took for something else.
|
|
27
|
+
* Report an error with the class and message of the error that was
|
|
28
|
+
raised, not of Minitest's wrapper around it.
|
|
29
|
+
* The count at the start of the stream follows Minitest's `--exclude`
|
|
30
|
+
option as well as `--name`, and the final total is the number of tests
|
|
31
|
+
that ran.
|
|
32
|
+
* Tests run in the order the seed gives them without Minitap. Counting
|
|
33
|
+
the tests used to disturb it.
|
|
34
|
+
* A record has no `subtype` when there is nothing to say, where it had
|
|
35
|
+
an empty one.
|
|
36
|
+
* The reporters are `Minitap::TapY` and `Minitap::TapJ`, subclasses of
|
|
37
|
+
`Minitap::Reporter`. `Minitest::TapY`, `Minitest::TapJ` and
|
|
38
|
+
`Minitest::Minitap` are gone, as is the `$RUBY_IGNORE_CALLERS` global.
|
|
39
|
+
* Require Tapout 0.5 or newer.
|
|
40
|
+
* Replace the old packaging (`.index`, `.gemspec`, `Assembly`, `MANIFEST`,
|
|
41
|
+
`var/`) with a plain `minitap.gemspec`, and Travis with GitHub Actions,
|
|
42
|
+
testing Ruby 2.7 to 4.0 with Minitest 5 and 6.
|
|
43
|
+
|
|
3
44
|
## 0.5.3 | 2013-11-20
|
|
4
45
|
|
|
5
46
|
Small change made to ensure that output i/o is un sync mode.
|
data/README.md
CHANGED
|
@@ -1,139 +1,142 @@
|
|
|
1
1
|
# Minitap
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[Source Code](http://github.com/rubyworks/minitap)
|
|
3
|
+
[Documentation](https://rubydoc.info/gems/minitap) |
|
|
4
|
+
[Report Issue](https://github.com/rubyworks/minitap/issues) |
|
|
5
|
+
[Source Code](https://github.com/rubyworks/minitap)
|
|
7
6
|
|
|
8
|
-
[](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund)
|
|
7
|
+
[](https://github.com/rubyworks/minitap/actions/workflows/ci.yml)
|
|
8
|
+
[](https://badge.fury.io/rb/minitap)
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
# About
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
with
|
|
13
|
+
Minitap is a [Minitest](https://github.com/minitest/minitest) plugin that
|
|
14
|
+
reports test results in TAP-Y or TAP-J. Those are the formats that
|
|
15
|
+
[Tapout](https://github.com/rubyworks/tapout) reads, so with Minitap a
|
|
16
|
+
Minitest suite can be shown in any of Tapout's report formats.
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
TAP-Y/J formats.
|
|
18
|
+
$ ruby -Ilib test/some_test.rb --tapy | tapout progress
|
|
21
19
|
|
|
20
|
+
Minitap works with Minitest 5.11 and newer, including Minitest 6, on
|
|
21
|
+
Ruby 2.7 and newer.
|
|
22
22
|
|
|
23
|
-
# Usage
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
# Installation
|
|
25
|
+
|
|
26
|
+
$ gem install minitap
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
of this new API to allow the TAP-Y or TAP-J formats to be selected via command-line
|
|
29
|
-
options as an alternative to setting the format in test helper scripts.
|
|
28
|
+
Or in a Gemfile:
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
gem 'minitap'
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
ruby test command invocation, e.g.
|
|
32
|
+
Tapout is installed along with it.
|
|
35
33
|
|
|
36
|
-
$ ruby -Ilib test/runner.rb - --tapy
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
# Usage
|
|
36
|
+
|
|
37
|
+
Load Minitap in your test helper, after Minitest:
|
|
39
38
|
|
|
40
39
|
require 'minitest/autorun'
|
|
40
|
+
require 'minitap'
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
That adds two options to the test command line, `--tapy` and `--tapj`.
|
|
43
|
+
Without one of them Minitest reports as usual.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
to install `tapout`:
|
|
45
|
+
$ ruby -Ilib test/some_test.rb --tapy
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
The output is a TAP-Y stream, which isn't meant to be read as it is.
|
|
48
|
+
Pipe it to `tapout`, with the name of the report you want:
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
$ ruby -Ilib test/some_test.rb --tapy | tapout progress
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
`tapout --help` lists the reports.
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
## With Rake
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
Rake's `TestTask` and Minitest's own `Minitest::TestTask` pass the
|
|
57
|
+
`TESTOPTS` variable on to Minitest:
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
require "minitap"
|
|
59
|
+
$ rake test TESTOPTS=--tapy | tapout progress
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Then pipe the output to the `tapout` command, e.g.
|
|
61
|
+
Rake's `-q` option keeps Rake's own output out of the stream.
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
## In code
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
To always report in TAP-Y or TAP-J, say so in the test helper:
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
require 'minitest/autorun'
|
|
68
|
+
require 'minitap'
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
Minitap.tapy! # or Minitap.tapj!
|
|
73
71
|
|
|
72
|
+
An option on the command line still takes precedence. `Minitap.format = :tapj`
|
|
73
|
+
does the same as `Minitap.tapj!`, which is handy with a variable:
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Minitap.format = ENV['TAP_FORMAT'] if ENV['TAP_FORMAT']
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
your Gemfile:
|
|
77
|
+
As a shorthand, `require 'minitap/autorun'` requires `minitest/autorun`
|
|
78
|
+
and chooses TAP-Y:
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
require 'minitap/autorun'
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
the `MiniTest::Unit.runner` to an instance of a custom runner class.
|
|
85
|
-
In our case we want to set it to an instance of `MiniTest::TapY` or `MiniTest::TapJ`.
|
|
86
|
-
So in your project's test helper script add, e.g.
|
|
82
|
+
## Loading the plugin
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
Minitap is an ordinary Minitest plugin, so Minitest's own ways of
|
|
85
|
+
loading one work as well as `require 'minitap'`:
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
environment variable.
|
|
87
|
+
Minitest.load :minitap
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
MiniTest::TapY.new
|
|
98
|
-
when 'tapj'
|
|
99
|
-
MiniTest::TapJ.new
|
|
100
|
-
end
|
|
89
|
+
Minitest 5 loads every installed plugin by itself, so there the options
|
|
90
|
+
are available without anything in the test helper. Minitest 6 no longer
|
|
91
|
+
does that, and one of the lines above is needed.
|
|
101
92
|
|
|
102
|
-
|
|
93
|
+
## What is reported
|
|
103
94
|
|
|
104
|
-
|
|
95
|
+
* Each test class is a case, and each test a test, labelled by name. A
|
|
96
|
+
spec is labelled as it was written.
|
|
97
|
+
* A failure or error comes with its message, the file and line in your
|
|
98
|
+
code, the lines of source around it, and a backtrace without Minitest
|
|
99
|
+
in it.
|
|
100
|
+
* A skipped test is reported as omitted, with the reason.
|
|
101
|
+
* What a test prints to `$stdout` and `$stderr` is captured and reported
|
|
102
|
+
with the test, since it would otherwise break the stream.
|
|
105
103
|
|
|
106
|
-
Now to do something interesting with the TAP-Y/J output, you will probably want
|
|
107
|
-
to install `tapout`:
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
# Upgrading from 0.5
|
|
110
106
|
|
|
111
|
-
|
|
107
|
+
Version 0.6 uses Minitest's plugin system only, and no longer needs the
|
|
108
|
+
`minitest-reporter-api` gem.
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
* `Minitest.reporter = Minitap::TapY` no longer does anything. Use
|
|
111
|
+
`Minitap.tapy!` instead.
|
|
112
|
+
* The reporters are `Minitap::TapY` and `Minitap::TapJ`. They are no
|
|
113
|
+
longer also defined as `Minitest::TapY` and `Minitest::TapJ`.
|
|
114
|
+
* Skipped tests have the status `omit`, as TAP-Y/J specifies. They used
|
|
115
|
+
to have the status `skip`.
|
|
116
|
+
|
|
117
|
+
For Minitest 4 and older, use Minitap 0.4.
|
|
114
118
|
|
|
115
119
|
|
|
116
120
|
# Using Pry & Other Tools
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
Because Tapout reads Minitest's output through a pipe, anything in the
|
|
123
|
+
stream that isn't TAP-Y/J may make it halt. A debugger needs the
|
|
124
|
+
terminal, though. For that there is a *pause code* (`16.chr`), which
|
|
125
|
+
tells `tapout` to stop reading test results and pass everything
|
|
126
|
+
straight through, and a *resume code* (`23.chr`), which starts it
|
|
127
|
+
reading again.
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
while using tapout:
|
|
129
|
+
With `binding.pry`, for example:
|
|
127
130
|
|
|
128
131
|
require 'tapout/utility'
|
|
129
132
|
tapout.pause{ binding.pry }
|
|
130
133
|
|
|
131
|
-
Or,
|
|
134
|
+
Or, more convenient still:
|
|
132
135
|
|
|
133
136
|
require 'tapout/utility'
|
|
134
137
|
tapout.pry(binding)
|
|
135
138
|
|
|
136
|
-
Which
|
|
139
|
+
Which amounts to:
|
|
137
140
|
|
|
138
141
|
STDOUT.puts 16.chr
|
|
139
142
|
binding.pry
|
|
@@ -150,5 +153,4 @@ Portions of this program were drawn from Alexander Kern's
|
|
|
150
153
|
MiniTest Reporter (c) 2011 Alexander Kern. Thanks Alexander
|
|
151
154
|
for making my endeavor a little bit easier.
|
|
152
155
|
|
|
153
|
-
See
|
|
154
|
-
|
|
156
|
+
See LICENSE.txt and NOTICE.md for copyright and licensing details.
|
data/demo/01_tapy.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# TAP-Y
|
|
2
|
+
|
|
3
|
+
Given a test file:
|
|
4
|
+
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
require 'minitap'
|
|
7
|
+
|
|
8
|
+
class ExampleTest < Minitest::Test
|
|
9
|
+
def test_error
|
|
10
|
+
raise "boom"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_failing
|
|
14
|
+
assert_equal('1', '2')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_passing
|
|
18
|
+
assert_equal('1', '1')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Running it with the `--tapy` option gives a TAP-Y stream.
|
|
23
|
+
|
|
24
|
+
stream = run_tapy('--tapy')
|
|
25
|
+
|
|
26
|
+
There are six documents in it.
|
|
27
|
+
|
|
28
|
+
stream.size #=> 6
|
|
29
|
+
|
|
30
|
+
The first is a `suite` with a count of `3`.
|
|
31
|
+
|
|
32
|
+
stream.first['type'] #=> 'suite'
|
|
33
|
+
stream.first['count'] #=> 3
|
|
34
|
+
stream.first['rev'] #=> 4
|
|
35
|
+
|
|
36
|
+
The second is a `case`, named after the test class.
|
|
37
|
+
|
|
38
|
+
stream[1]['type'] #=> 'case'
|
|
39
|
+
stream[1]['label'] #=> 'ExampleTest'
|
|
40
|
+
stream[1]['level'] #=> 0
|
|
41
|
+
|
|
42
|
+
The next three are the tests, which can come in any order.
|
|
43
|
+
|
|
44
|
+
tests = tests(stream)
|
|
45
|
+
|
|
46
|
+
tests.size #=> 3
|
|
47
|
+
|
|
48
|
+
The passing test has little to say.
|
|
49
|
+
|
|
50
|
+
tests['test_passing']['status'] #=> 'pass'
|
|
51
|
+
tests['test_passing']['exception'] #=> nil
|
|
52
|
+
|
|
53
|
+
The failing test says what failed and where in the test file.
|
|
54
|
+
|
|
55
|
+
failing = tests['test_failing']
|
|
56
|
+
|
|
57
|
+
failing['status'] #=> 'fail'
|
|
58
|
+
failing['exception']['class'] #=> 'Minitest::Assertion'
|
|
59
|
+
failing['exception']['file'] #=> 'test.rb'
|
|
60
|
+
failing['exception']['line'] #=> 10
|
|
61
|
+
failing['exception']['source'] #=> "assert_equal('1', '2')"
|
|
62
|
+
|
|
63
|
+
failing['exception']['message'].assert.include?('Expected: "1"')
|
|
64
|
+
|
|
65
|
+
It comes with the lines around the failure.
|
|
66
|
+
|
|
67
|
+
failing['exception']['snippet'].map { |line| line.keys.first } #=> [8, 9, 10, 11, 12]
|
|
68
|
+
failing['exception']['snippet'][2][10] #=> " assert_equal('1', '2')"
|
|
69
|
+
|
|
70
|
+
The test that raised an error names the error, not Minitest's wrapper
|
|
71
|
+
for it.
|
|
72
|
+
|
|
73
|
+
erring = tests['test_error']
|
|
74
|
+
|
|
75
|
+
erring['status'] #=> 'error'
|
|
76
|
+
erring['exception']['class'] #=> 'RuntimeError'
|
|
77
|
+
erring['exception']['message'] #=> 'boom'
|
|
78
|
+
erring['exception']['file'] #=> 'test.rb'
|
|
79
|
+
erring['exception']['line'] #=> 6
|
|
80
|
+
erring['exception']['source'] #=> 'raise "boom"'
|
|
81
|
+
|
|
82
|
+
Neither backtrace mentions Minitest or Minitap.
|
|
83
|
+
|
|
84
|
+
failing['exception']['backtrace'] #=> ['test.rb:10']
|
|
85
|
+
erring['exception']['backtrace'] #=> ['test.rb:6']
|
|
86
|
+
|
|
87
|
+
The last document is the `final` one, with the counts.
|
|
88
|
+
|
|
89
|
+
stream.last['type'] #=> 'final'
|
|
90
|
+
stream.last['counts'] #=> {'total'=>3, 'pass'=>1, 'fail'=>1, 'error'=>1, 'omit'=>0, 'todo'=>0}
|
|
91
|
+
|
|
92
|
+
The stream ends with the YAML end-of-document marker.
|
|
93
|
+
|
|
94
|
+
@stdout.lines.last #=> "...\n"
|
|
95
|
+
|
|
96
|
+
Nothing else is written, and the exit status still tells of the
|
|
97
|
+
failures.
|
|
98
|
+
|
|
99
|
+
@stderr #=> ''
|
|
100
|
+
@status.success? #=> false
|
data/demo/02_tapj.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# TAP-J
|
|
2
|
+
|
|
3
|
+
Given a test file:
|
|
4
|
+
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
require 'minitap'
|
|
7
|
+
|
|
8
|
+
class ExampleTest < Minitest::Test
|
|
9
|
+
def test_failing
|
|
10
|
+
assert_equal('1', '2')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_passing
|
|
14
|
+
assert_equal('1', '1')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Running it with the `--tapj` option gives a TAP-J stream: the same
|
|
19
|
+
records as TAP-Y, as a JSON document on each line.
|
|
20
|
+
|
|
21
|
+
stream = run_tapj('--tapj')
|
|
22
|
+
|
|
23
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'test', 'final']
|
|
24
|
+
|
|
25
|
+
tests = tests(stream)
|
|
26
|
+
|
|
27
|
+
tests['test_passing']['status'] #=> 'pass'
|
|
28
|
+
tests['test_failing']['status'] #=> 'fail'
|
|
29
|
+
tests['test_failing']['exception']['file'] #=> 'test.rb'
|
|
30
|
+
tests['test_failing']['exception']['line'] #=> 6
|
|
31
|
+
|
|
32
|
+
stream.last['counts'] #=> {'total'=>2, 'pass'=>1, 'fail'=>1, 'error'=>0, 'omit'=>0, 'todo'=>0}
|
data/demo/03_spec.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Minitest::Spec
|
|
2
|
+
|
|
3
|
+
Given a test file:
|
|
4
|
+
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
require 'minitap'
|
|
7
|
+
|
|
8
|
+
describe "Example Case" do
|
|
9
|
+
it "should error" do
|
|
10
|
+
raise "boom"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should fail" do
|
|
14
|
+
assert_equal('1', '2')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should pass" do
|
|
18
|
+
assert_equal('1', '1')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
A spec is reported like any other test.
|
|
23
|
+
|
|
24
|
+
stream = run_tapy('--tapy')
|
|
25
|
+
|
|
26
|
+
stream.size #=> 6
|
|
27
|
+
|
|
28
|
+
The case is labelled with the description.
|
|
29
|
+
|
|
30
|
+
stream[1]['type'] #=> 'case'
|
|
31
|
+
stream[1]['label'] #=> 'Example Case'
|
|
32
|
+
|
|
33
|
+
The tests are labelled as they were written, without the `test_0001_`
|
|
34
|
+
that Minitest puts in front.
|
|
35
|
+
|
|
36
|
+
tests = tests(stream)
|
|
37
|
+
|
|
38
|
+
tests.keys.sort #=> ['should error', 'should fail', 'should pass']
|
|
39
|
+
|
|
40
|
+
tests['should pass']['status'] #=> 'pass'
|
|
41
|
+
tests['should fail']['status'] #=> 'fail'
|
|
42
|
+
tests['should error']['status'] #=> 'error'
|
|
43
|
+
|
|
44
|
+
tests['should fail']['exception']['line'] #=> 10
|
|
45
|
+
tests['should error']['exception']['line'] #=> 6
|
data/demo/04_helper.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Choosing the format in code
|
|
2
|
+
|
|
3
|
+
The format can be chosen in a test helper instead of on the command
|
|
4
|
+
line.
|
|
5
|
+
|
|
6
|
+
Given a test file:
|
|
7
|
+
|
|
8
|
+
require 'minitest/autorun'
|
|
9
|
+
require 'minitap'
|
|
10
|
+
|
|
11
|
+
Minitap.tapj!
|
|
12
|
+
|
|
13
|
+
class ExampleTest < Minitest::Test
|
|
14
|
+
def test_passing
|
|
15
|
+
assert true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then it needs no option.
|
|
20
|
+
|
|
21
|
+
stream = run_tapj
|
|
22
|
+
|
|
23
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'final']
|
|
24
|
+
|
|
25
|
+
An option on the command line takes precedence.
|
|
26
|
+
|
|
27
|
+
stream = run_tapy('--tapy')
|
|
28
|
+
|
|
29
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'final']
|
|
30
|
+
|
|
31
|
+
## minitap/autorun
|
|
32
|
+
|
|
33
|
+
Requiring `minitap/autorun` is `minitest/autorun` with TAP-Y chosen.
|
|
34
|
+
|
|
35
|
+
Given a test file:
|
|
36
|
+
|
|
37
|
+
require 'minitap/autorun'
|
|
38
|
+
|
|
39
|
+
class ExampleTest < Minitest::Test
|
|
40
|
+
def test_passing
|
|
41
|
+
assert true
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then:
|
|
46
|
+
|
|
47
|
+
stream = run_tapy
|
|
48
|
+
|
|
49
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'final']
|
|
50
|
+
|
|
51
|
+
Here too an option can ask for the other format.
|
|
52
|
+
|
|
53
|
+
stream = run_tapj('--tapj')
|
|
54
|
+
|
|
55
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'final']
|
|
56
|
+
|
|
57
|
+
## Without a format
|
|
58
|
+
|
|
59
|
+
Requiring Minitap chooses nothing by itself.
|
|
60
|
+
|
|
61
|
+
Given a test file:
|
|
62
|
+
|
|
63
|
+
require 'minitest/autorun'
|
|
64
|
+
require 'minitap'
|
|
65
|
+
|
|
66
|
+
class ExampleTest < Minitest::Test
|
|
67
|
+
def test_passing
|
|
68
|
+
assert true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Without an option, Minitest reports as it always does.
|
|
73
|
+
|
|
74
|
+
out = run_tests
|
|
75
|
+
|
|
76
|
+
out.assert.include?('1 runs, 1 assertions, 0 failures, 0 errors, 0 skips')
|
|
77
|
+
|
|
78
|
+
An unknown format is refused.
|
|
79
|
+
|
|
80
|
+
require 'minitap'
|
|
81
|
+
|
|
82
|
+
ArgumentError.assert.raised? do
|
|
83
|
+
Minitap.format = :xml
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Minitap.format #=> nil
|
|
87
|
+
|
|
88
|
+
## Minitest's plugin loader
|
|
89
|
+
|
|
90
|
+
Minitest can also be told to load the plugin by name.
|
|
91
|
+
|
|
92
|
+
Given a test file:
|
|
93
|
+
|
|
94
|
+
require 'minitest/autorun'
|
|
95
|
+
|
|
96
|
+
Minitest.load :minitap if Minitest.respond_to?(:load)
|
|
97
|
+
|
|
98
|
+
class ExampleTest < Minitest::Test
|
|
99
|
+
def test_passing
|
|
100
|
+
assert true
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
Then the options are there. (Minitest 5 finds an installed plugin
|
|
105
|
+
without being told, so there it works either way.)
|
|
106
|
+
|
|
107
|
+
stream = run_tapy('--tapy')
|
|
108
|
+
|
|
109
|
+
stream.map { |d| d['type'] } #=> ['suite', 'case', 'test', 'final']
|