minitest-reporters-json_reporter 0.9.12 → 1.0.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 +4 -4
- data/.codeclimate.yml +1 -1
- data/Announcement.txt +13 -12
- data/README.md +3 -7
- data/doc/Minitest.html +1 -1
- data/doc/Minitest/Reporters.html +1 -1
- data/doc/Minitest/Reporters/JsonReporter.html +11 -11
- data/doc/_index.html +1 -1
- data/doc/file.README.html +171 -22
- data/doc/index.html +171 -22
- data/doc/top-level-namespace.html +1 -1
- data/lib/minitest/reporters/json_reporter.rb +6 -6
- data/lib/minitest/reporters/json_reporter/version.rb +1 -1
- data/minitest-reporters-json_reporter.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 137b4c93b51f77e64563dc73e0fee830b729473f
|
4
|
+
data.tar.gz: a0ca90654ccd75f2d10b5ef8fcb85764dca50d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd1a72b03cd22c919dc614d3431d5489e2b74482fa7b30426d46b0da6f79590bed226281ed6fa79b4a72afc831c1737683c2af8ac68663e2da9775b231affbcc
|
7
|
+
data.tar.gz: eee8241a1c266566687ed8594c7b3262819b23db87970fb353c67ea23764a7360d4d341758763bc60ef9c060027be453c379e1f4932186e06f6305c0b1dff56f
|
data/.codeclimate.yml
CHANGED
data/Announcement.txt
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
-
minitest-reporters-json_reporter version 0.
|
1
|
+
minitest-reporters-json_reporter version 1.0.0 has been released.
|
2
2
|
|
3
3
|
Home, Code: https://github.com/edhowland/minitest-reporters-json_reporter
|
4
4
|
Bugs: https://github.com/edhowland/minitest-reporters-json_reporter/issues
|
5
|
-
Docs:http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.
|
5
|
+
Docs:http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0
|
6
6
|
|
7
7
|
minitest-reporters-json_reporter is an extension to the Ruby minitest-reporters gem that provides JSON output from your Minitest or MiniSpec test run.
|
8
|
-
This version is the beta/release candidate before the official 1.0 version.
|
9
8
|
|
10
9
|
Changes:
|
10
|
+
o Badges! We have stinkin' badges.
|
11
|
+
o Improved class/method documentation.
|
12
|
+
o README.md contains better and more 'jq' examples.
|
11
13
|
|
12
|
-
|
13
|
-
o conformant with Minitest::Reporters superclass.
|
14
|
-
o Simpler and easy to customize.
|
15
|
-
o More inclusive of elements from the Minitest test run.
|
16
|
-
o Includes:
|
17
|
-
o Timings.
|
18
|
-
o Count of assertions.
|
14
|
+
This version forms the foundation for the PR on the upstream minitest-reporters gem.
|
19
15
|
|
20
16
|
Abstract
|
21
17
|
|
@@ -24,9 +20,14 @@ for Minitest, but no JSON format until now. If you want to hook up an IDE or som
|
|
24
20
|
framework like a CI or CD tool, it is natural to send output in some parsable format like XML or JSON. This extension summarizes the result of
|
25
21
|
a test run in format like JSON.a test run in an easible consumable format.
|
26
22
|
|
23
|
+
Another use case is doing data mining on your test runs. Using a tool like 'jq',
|
24
|
+
you canspot trends, find long running tests and group test failures in some
|
25
|
+
order.
|
27
26
|
|
28
|
-
Usage is very simple. Just require 'minitest/reporters/json_reporter' in your
|
29
|
-
|
27
|
+
Usage is very simple. Just require 'minitest/reporters/json_reporter' in your
|
28
|
+
test_helper.rb or spec_helper.rb.
|
29
|
+
Then, you should also invoke the use! method of Minitest::Reporters class
|
30
|
+
with a call to Minitest::Reporters::JsonReporter.new.
|
30
31
|
Here is an example test_helper.rb:
|
31
32
|
# ... Other requires
|
32
33
|
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ See the 'jq sort' example below.
|
|
21
21
|
I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: [https://github.com/edhowland/viper](https://github.com/edhowland/viper)
|
22
22
|
Using this gem with Viper also requires the 'viper_ruby' package. See [https://github.com/edhowland/viper_ruby](https://github.com/edhowland/viper_ruby)
|
23
23
|
|
24
|
-
## Version 0.
|
24
|
+
## Version 1.0.0
|
25
25
|
|
26
26
|
## Installation
|
27
27
|
|
@@ -124,7 +124,7 @@ $ ruby report_spec.rb | jq .
|
|
124
124
|
"status": { "code": "Failed", "color": "red" },
|
125
125
|
"metadata": {
|
126
126
|
"generated_by": "Minitest::Reporters::JsonReporter",
|
127
|
-
"version": "0.
|
127
|
+
"version": "1.0.0",
|
128
128
|
"ruby_version": "2.2.2",
|
129
129
|
"ruby_patchlevel": 95,
|
130
130
|
"ruby_platform": "x86_64-linux",
|
@@ -237,10 +237,6 @@ $ ruby group_by_spec.rb |jq '.fails | group_by(.class) | flatten[] | .class, .na
|
|
237
237
|
"test_value_length_equals_2"
|
238
238
|
```
|
239
239
|
|
240
|
-
Note the above result is an array of 2 arrays grouped by the .class key.
|
241
|
-
|
242
|
-
|
243
|
-
|
244
240
|
|
245
241
|
## Customizing the JSON format
|
246
242
|
|
@@ -281,7 +277,7 @@ Note: Extra credit if git flow feature branching was used.
|
|
281
277
|
|
282
278
|
* Code: [https://github.com/edhowland/minitest-reporters-json_reporter](https://github.com/edhowland/minitest-reporters-json_reporter)
|
283
279
|
* Bugs: [https://github.com/edhowland/minitest-reporters-json_reporter/issues](https://github.com/edhowland/minitest-reporters-json_reporter/issues)
|
284
|
-
* Docs: [http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.
|
280
|
+
* Docs: [http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0](http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0)
|
285
281
|
* Gem: [https://rubygems.org/gems/minitest-reporters-json_reporter](https://rubygems.org/gems/minitest-reporters-json_reporter)
|
286
282
|
|
287
283
|
###### Feedback
|
data/doc/Minitest.html
CHANGED
@@ -119,7 +119,7 @@
|
|
119
119
|
</div>
|
120
120
|
|
121
121
|
<div id="footer">
|
122
|
-
Generated on
|
122
|
+
Generated on Wed May 25 22:22:25 2016 by
|
123
123
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
124
124
|
0.8.7.6 (ruby-2.2.2).
|
125
125
|
</div>
|
data/doc/Minitest/Reporters.html
CHANGED
@@ -120,7 +120,7 @@ href="https://github.com/kern/minitest-reporters">github.com/kern/minitest-repor
|
|
120
120
|
</div>
|
121
121
|
|
122
122
|
<div id="footer">
|
123
|
-
Generated on
|
123
|
+
Generated on Wed May 25 22:22:25 2016 by
|
124
124
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
125
125
|
0.8.7.6 (ruby-2.2.2).
|
126
126
|
</div>
|
@@ -134,7 +134,7 @@ editor.</p>
|
|
134
134
|
|
135
135
|
</div>
|
136
136
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.
|
137
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
138
138
|
|
139
139
|
</dl>
|
140
140
|
|
@@ -270,12 +270,12 @@ E.g. :verbose => true</p>
|
|
270
270
|
<pre class="lines">
|
271
271
|
|
272
272
|
|
273
|
+
21
|
273
274
|
22
|
274
|
-
23
|
275
|
-
24</pre>
|
275
|
+
23</pre>
|
276
276
|
</td>
|
277
277
|
<td>
|
278
|
-
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line
|
278
|
+
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line 21</span>
|
279
279
|
|
280
280
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
281
281
|
<span class='kw'>super</span>
|
@@ -318,12 +318,12 @@ E.g. :verbose => true</p>
|
|
318
318
|
<pre class="lines">
|
319
319
|
|
320
320
|
|
321
|
+
27
|
321
322
|
28
|
322
|
-
29
|
323
|
-
30</pre>
|
323
|
+
29</pre>
|
324
324
|
</td>
|
325
325
|
<td>
|
326
|
-
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line
|
326
|
+
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line 27</span>
|
327
327
|
|
328
328
|
<span class='kw'>def</span> <span class='id identifier rubyid_storage'>storage</span>
|
329
329
|
<span class='ivar'>@storage</span>
|
@@ -367,16 +367,16 @@ of to_h to JSON and calls io.write to output it.</p>
|
|
367
367
|
<pre class="lines">
|
368
368
|
|
369
369
|
|
370
|
+
32
|
370
371
|
33
|
371
372
|
34
|
372
373
|
35
|
373
374
|
36
|
374
375
|
37
|
375
|
-
38
|
376
|
-
39</pre>
|
376
|
+
38</pre>
|
377
377
|
</td>
|
378
378
|
<td>
|
379
|
-
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line
|
379
|
+
<pre class="code"><span class="info file"># File 'lib/minitest/reporters/json_reporter.rb', line 32</span>
|
380
380
|
|
381
381
|
<span class='kw'>def</span> <span class='id identifier rubyid_report'>report</span>
|
382
382
|
<span class='kw'>super</span>
|
@@ -395,7 +395,7 @@ of to_h to JSON and calls io.write to output it.</p>
|
|
395
395
|
</div>
|
396
396
|
|
397
397
|
<div id="footer">
|
398
|
-
Generated on
|
398
|
+
Generated on Wed May 25 22:22:25 2016 by
|
399
399
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
400
400
|
0.8.7.6 (ruby-2.2.2).
|
401
401
|
</div>
|
data/doc/_index.html
CHANGED
@@ -131,7 +131,7 @@
|
|
131
131
|
</div>
|
132
132
|
|
133
133
|
<div id="footer">
|
134
|
-
Generated on
|
134
|
+
Generated on Wed May 25 22:22:25 2016 by
|
135
135
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
136
136
|
0.8.7.6 (ruby-2.2.2).
|
137
137
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -65,15 +65,25 @@
|
|
65
65
|
|
66
66
|
<p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.</p>
|
67
67
|
|
68
|
-
<p
|
68
|
+
<p><a href="https://badge.fury.io/rb/minitest-reporters-json_reporter"><img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version"></a>
|
69
|
+
<a href="https://travis-ci.org/edhowland/minitest-reporters-json_reporter"><img src="https://travis-ci.org/edhowland/minitest-reporters-json_reporter.png?branch=master" alt="Build Status"></a>
|
70
|
+
<a href="https://coveralls.io/github/edhowland/minitest-reporters-json_reporter?branch=master"><img src="https://coveralls.io/repos/github/edhowland/minitest-reporters-json_reporter/badge.svg?branch=master" alt="Coverage Status"></a>
|
71
|
+
<a href="https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter"><img src="https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter/badges/gpa.svg" alt="Code Climate"></a>
|
72
|
+
<a href="http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter"><img src="http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter.svg?style=shields" alt="Inline docs"></a></p>
|
69
73
|
|
70
74
|
<h2>Abstract</h2>
|
71
75
|
|
72
76
|
<p>You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
|
73
|
-
example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a>
|
74
|
-
I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: <a href="https://github.com/edhowland/viper">https://github.com/edhowland/viper</a></p>
|
77
|
+
example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a></p>
|
75
78
|
|
76
|
-
<
|
79
|
+
<p>Use of JSON as a format for test runs opens up possibilities for different types of analysis.
|
80
|
+
You can organize the output based on elapsed time or number of assertions of tests, for example.
|
81
|
+
See the 'jq sort' example below.</p>
|
82
|
+
|
83
|
+
<p>I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: <a href="https://github.com/edhowland/viper">https://github.com/edhowland/viper</a>
|
84
|
+
Using this gem with Viper also requires the 'viper_ruby' package. See <a href="https://github.com/edhowland/viper_ruby">https://github.com/edhowland/viper_ruby</a></p>
|
85
|
+
|
86
|
+
<h2>Version 1.0.0</h2>
|
77
87
|
|
78
88
|
<h2>Installation</h2>
|
79
89
|
|
@@ -108,29 +118,151 @@ I originally wrote this gem to interface to the Viper audible code editor for t
|
|
108
118
|
|
109
119
|
<h2>Object Summary</h2>
|
110
120
|
|
111
|
-
<
|
112
|
-
<li>status
|
113
|
-
|
114
|
-
<
|
115
|
-
<li>
|
116
|
-
<li>
|
117
|
-
</
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<
|
122
|
-
|
123
|
-
|
124
|
-
<
|
125
|
-
<li>
|
126
|
-
<li>
|
127
|
-
|
121
|
+
<ul>
|
122
|
+
<li>status of the overall test run. Object.
|
123
|
+
|
124
|
+
<ul>
|
125
|
+
<li>code - Success, Passed with skipped tests or Failed. String.</li>
|
126
|
+
<li>color green, yellow or red. String.</li>
|
127
|
+
</ul></li>
|
128
|
+
<li>metadata The metadata of this particular test run. Object.
|
129
|
+
|
130
|
+
<ul>
|
131
|
+
<li>generated_by Class name of the Minitest Reporter. Will usually be Minitest::Reporters::JsonReporter. String.</li>
|
132
|
+
<li>version - Version of the minitest-reporters-json_reporter gem. String.</li>
|
133
|
+
<li>ruby_version - RUBY_VERSION. String.</li>
|
134
|
+
<li>ruby_patchlevel - RUBY_PATCHLEVEL. Integer.</li>
|
135
|
+
<li>ruby_platform - RUBY_PLATFORM. String.</li>
|
136
|
+
<li>time - Time of test run in UTC and ISO-8601 format. String.</li>
|
137
|
+
<li>options - Options object as constructed by passed options, superclasses and command line args. Object.</li>
|
138
|
+
<li>io - The class name of the IO object. Will be the string 'STDOUT' if equal to $stdout. String.</li>
|
139
|
+
<li>keys of the options hash, if any. Various key/value pairs.</li>
|
140
|
+
<li>args Array of arguments passed to the program. Array of String.</li>
|
141
|
+
<li>total_count - Total number of tests ran. Integer.</li>
|
142
|
+
</ul></li>
|
143
|
+
<li>statisticsThe accumulated counts for this test run. Object.
|
144
|
+
|
145
|
+
<ul>
|
146
|
+
<li>total Number of total runs. Integer.</li>
|
147
|
+
<li>assertions Count of assertions performed. Integer.</li>
|
148
|
+
<li>failures Number of failed tests. Integer.</li>
|
149
|
+
<li>errors Number of errors encountered. Integer.</li>
|
150
|
+
<li>skips Number of skipped tests. Integer.</li>
|
151
|
+
<li>passes Number of passed tests. Integer.</li>
|
152
|
+
</ul></li>
|
153
|
+
<li>timings Object containing the computed timing information for the entire test run. Object.
|
154
|
+
|
155
|
+
<ul>
|
156
|
+
<li>total_seconds total number of seconds for the entire test run. Float.</li>
|
157
|
+
<li>runs_per_second Averaged number of runs per second. Float.</li>
|
158
|
+
<li>assertions_per_second Averaged number of assertions per second. Float.</li>
|
159
|
+
</ul></li>
|
160
|
+
<li>fails - Array of failed or errored tests. Array of Object.
|
161
|
+
|
162
|
+
<ul>
|
163
|
+
<li>type Type of the failure. Either 'failure' or 'error'. String.</li>
|
164
|
+
<li>classClass name of the test. String.</li>
|
165
|
+
<li>name Name of the test. String.</li>
|
166
|
+
<li>assertions Number of the assertions for this test. Integer.</li>
|
167
|
+
<li>time Time in seconds for this test. Float.</li>
|
168
|
+
<li>message Message reported by this failure or error. String.</li>
|
169
|
+
<li>location File name and line number. file:line. String.</li>
|
170
|
+
<li>backtrace (exists only if type is 'error') Array of backtrace paths and line numbers. Array of String.</li>
|
171
|
+
</ul></li>
|
172
|
+
<li>skips Array of skipped tests. Array of Object.
|
173
|
+
|
174
|
+
<ul>
|
175
|
+
<li>type The string 'skipped'. String.</li>
|
176
|
+
<li>class Class name of the test. String.</li>
|
177
|
+
<li>name The name of the test. String.</li>
|
178
|
+
<li>assertions The count of the assertions for this test. Integer.</li>
|
179
|
+
<li>time The time of this test in seconds. Float.</li>
|
180
|
+
<li>message The message string passed to the 'skip()' method. String.</li>
|
181
|
+
<li>location File name and line number. file:line. String.</li>
|
182
|
+
</ul></li>
|
183
|
+
<li>passes Array of passed test runs. Array of Object.
|
184
|
+
|
185
|
+
<ul>
|
186
|
+
<li>type The string 'passed'. String.</li>
|
187
|
+
<li>class Class name of the test. String.</li>
|
188
|
+
<li>name The name of the test. String.</li>
|
189
|
+
<li>assertions The count of the assertions for this test. Integer.</li>
|
190
|
+
<li>time The time of this test in seconds. Float.</li>
|
191
|
+
</ul></li>
|
192
|
+
</ul>
|
193
|
+
|
194
|
+
<p>The last 2 objects: skips[] and passes[] are absent unless the --verbose command
|
195
|
+
line flag was passed or if the options[:verbose] value is true.</p>
|
128
196
|
|
129
197
|
<h3>Sample output</h3>
|
130
198
|
|
131
199
|
<pre class="code ruby"><code class="ruby"><span class='comment'># Use jq to pretty print the JSON output
|
132
200
|
</span></code></pre>
|
133
201
|
|
202
|
+
<h2>Example analysis feedback</h2>
|
203
|
+
|
204
|
+
<p>JSON can be parsed and manipulated to provide many types of useful information.
|
205
|
+
Below are some example usages.
|
206
|
+
We use the 'jq' program to parse and select and arrange the output.
|
207
|
+
The version of 'jq' is 1.5. It can be downloaded/install instructions here: <a href="https://stedolan.github.io/jq/download/">Download JQ</a>
|
208
|
+
See: <a href="https://stedolan.github.io/jq/manual/">JQ Developer Manual</a></p>
|
209
|
+
|
210
|
+
<h3>Sort by time, slowest first</h3>
|
211
|
+
|
212
|
+
<p>This sort would show you the slowest tests first, getting faster further down the array.
|
213
|
+
Similar to Minitest::Reporters::MeanTimeReporter which produces a report summary showing the slowest running tests.</p>
|
214
|
+
|
215
|
+
<pre class="code ruby"><code class="ruby">$ ruby timings_spec.rb --verbose | jq '.passes | sort_by(.time) | reverse[] | .name, .time'
|
216
|
+
"test_0001_should be slow"
|
217
|
+
5.001584862009622
|
218
|
+
"test_0003_should be slightly faster"
|
219
|
+
1.0003409570199437
|
220
|
+
"test_0002_should be fast"
|
221
|
+
2.9060000088065863e-05
|
222
|
+
</code></pre>
|
223
|
+
|
224
|
+
<h3>Group By Class example</h3>
|
225
|
+
|
226
|
+
<p>Minitest usually runs your tests in a random sequence. This is
|
227
|
+
great for test isolation and to check for state bleed-thru, but can be annoying if trying
|
228
|
+
to determine where similar tests are failing. You can use the jq 'sort_by' or 'group_by' filters to get them back in
|
229
|
+
some semblace of order.</p>
|
230
|
+
|
231
|
+
<p>Here we group the .fails[] array by their class name. (The file: 'group_by_spec.rb'
|
232
|
+
contains 4 tests inside 2 classes.)</p>
|
233
|
+
|
234
|
+
<pre class="code ruby"><code class="ruby">$ ruby group_by_spec.rb |jq '.fails | group_by(.class) | flatten[] | .class, .name'
|
235
|
+
"TestNumericalGroup"
|
236
|
+
"test_4_times_6_equals_24"
|
237
|
+
"TestNumericalGroup"
|
238
|
+
"test_positive_integers_are_greater_than_0"
|
239
|
+
"TestStringGroup"
|
240
|
+
"test_string_is_hello_world"
|
241
|
+
"TestStringGroup"
|
242
|
+
"test_value_length_equals_2"
|
243
|
+
</code></pre>
|
244
|
+
|
245
|
+
<h2>Customizing the JSON format</h2>
|
246
|
+
|
247
|
+
<p>You can adjust the contents of the returned JSON by sub-classing the Minitest::Reporters::JsonReporter class.
|
248
|
+
Override the 'to_h' method and delete or modifythe hash it returns.</p>
|
249
|
+
|
250
|
+
<p>Here is a simple example that eliminates the 'metadata' and 'timmings' components:</p>
|
251
|
+
|
252
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># example spec_helper.rb:
|
253
|
+
</span>
|
254
|
+
<span class='kw'>class</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>SlimJsonReporter</span> <span class='op'><</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>JsonReporter</span>
|
255
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span>
|
256
|
+
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='kw'>super</span>
|
257
|
+
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:metadata</span><span class='rparen'>)</span>
|
258
|
+
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:timings</span><span class='rparen'>)</span>
|
259
|
+
<span class='id identifier rubyid_h'>h</span>
|
260
|
+
<span class='kw'>end</span>
|
261
|
+
<span class='kw'>end</span>
|
262
|
+
|
263
|
+
<span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='period'>.</span><span class='id identifier rubyid_use!'>use!</span><span class='lparen'>(</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>SlimJsonReporter</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='rparen'>)</span>
|
264
|
+
</code></pre>
|
265
|
+
|
134
266
|
<h2>Contributing</h2>
|
135
267
|
|
136
268
|
<ol>
|
@@ -142,10 +274,27 @@ you will get 2 additional objects: skips[] and passes[]</p>
|
|
142
274
|
</ol>
|
143
275
|
|
144
276
|
<p>Note: Extra credit if git flow feature branching was used.</p>
|
277
|
+
|
278
|
+
<h2>Resources</h2>
|
279
|
+
|
280
|
+
<ul>
|
281
|
+
<li>Code: <a href="https://github.com/edhowland/minitest-reporters-json_reporter">https://github.com/edhowland/minitest-reporters-json_reporter</a></li>
|
282
|
+
<li>Bugs: <a href="https://github.com/edhowland/minitest-reporters-json_reporter/issues">https://github.com/edhowland/minitest-reporters-json_reporter/issues</a></li>
|
283
|
+
<li>Docs: <a href="http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0">http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0</a></li>
|
284
|
+
<li>Gem: <a href="https://rubygems.org/gems/minitest-reporters-json_reporter">https://rubygems.org/gems/minitest-reporters-json_reporter</a></li>
|
285
|
+
</ul>
|
286
|
+
|
287
|
+
<h6>Feedback</h6>
|
288
|
+
|
289
|
+
<p>If you find this gem helpful, please slip me a note via e-mail: <a href="mailto:ed.howland@gmail.com">ed.howland@gmail.com</a></p>
|
290
|
+
|
291
|
+
<p>I would like to know if anyone has used this approach to interface Minitest to any automated framework or editor.</p>
|
292
|
+
|
293
|
+
<p>Thanks, Ed.</p>
|
145
294
|
</div></div>
|
146
295
|
|
147
296
|
<div id="footer">
|
148
|
-
Generated on
|
297
|
+
Generated on Wed May 25 22:22:25 2016 by
|
149
298
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
150
299
|
0.8.7.6 (ruby-2.2.2).
|
151
300
|
</div>
|
data/doc/index.html
CHANGED
@@ -65,15 +65,25 @@
|
|
65
65
|
|
66
66
|
<p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.</p>
|
67
67
|
|
68
|
-
<p
|
68
|
+
<p><a href="https://badge.fury.io/rb/minitest-reporters-json_reporter"><img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version"></a>
|
69
|
+
<a href="https://travis-ci.org/edhowland/minitest-reporters-json_reporter"><img src="https://travis-ci.org/edhowland/minitest-reporters-json_reporter.png?branch=master" alt="Build Status"></a>
|
70
|
+
<a href="https://coveralls.io/github/edhowland/minitest-reporters-json_reporter?branch=master"><img src="https://coveralls.io/repos/github/edhowland/minitest-reporters-json_reporter/badge.svg?branch=master" alt="Coverage Status"></a>
|
71
|
+
<a href="https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter"><img src="https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter/badges/gpa.svg" alt="Code Climate"></a>
|
72
|
+
<a href="http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter"><img src="http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter.svg?style=shields" alt="Inline docs"></a></p>
|
69
73
|
|
70
74
|
<h2>Abstract</h2>
|
71
75
|
|
72
76
|
<p>You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
|
73
|
-
example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a>
|
74
|
-
I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: <a href="https://github.com/edhowland/viper">https://github.com/edhowland/viper</a></p>
|
77
|
+
example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a></p>
|
75
78
|
|
76
|
-
<
|
79
|
+
<p>Use of JSON as a format for test runs opens up possibilities for different types of analysis.
|
80
|
+
You can organize the output based on elapsed time or number of assertions of tests, for example.
|
81
|
+
See the 'jq sort' example below.</p>
|
82
|
+
|
83
|
+
<p>I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: <a href="https://github.com/edhowland/viper">https://github.com/edhowland/viper</a>
|
84
|
+
Using this gem with Viper also requires the 'viper_ruby' package. See <a href="https://github.com/edhowland/viper_ruby">https://github.com/edhowland/viper_ruby</a></p>
|
85
|
+
|
86
|
+
<h2>Version 1.0.0</h2>
|
77
87
|
|
78
88
|
<h2>Installation</h2>
|
79
89
|
|
@@ -108,29 +118,151 @@ I originally wrote this gem to interface to the Viper audible code editor for t
|
|
108
118
|
|
109
119
|
<h2>Object Summary</h2>
|
110
120
|
|
111
|
-
<
|
112
|
-
<li>status
|
113
|
-
|
114
|
-
<
|
115
|
-
<li>
|
116
|
-
<li>
|
117
|
-
</
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
<
|
122
|
-
|
123
|
-
|
124
|
-
<
|
125
|
-
<li>
|
126
|
-
<li>
|
127
|
-
|
121
|
+
<ul>
|
122
|
+
<li>status of the overall test run. Object.
|
123
|
+
|
124
|
+
<ul>
|
125
|
+
<li>code - Success, Passed with skipped tests or Failed. String.</li>
|
126
|
+
<li>color green, yellow or red. String.</li>
|
127
|
+
</ul></li>
|
128
|
+
<li>metadata The metadata of this particular test run. Object.
|
129
|
+
|
130
|
+
<ul>
|
131
|
+
<li>generated_by Class name of the Minitest Reporter. Will usually be Minitest::Reporters::JsonReporter. String.</li>
|
132
|
+
<li>version - Version of the minitest-reporters-json_reporter gem. String.</li>
|
133
|
+
<li>ruby_version - RUBY_VERSION. String.</li>
|
134
|
+
<li>ruby_patchlevel - RUBY_PATCHLEVEL. Integer.</li>
|
135
|
+
<li>ruby_platform - RUBY_PLATFORM. String.</li>
|
136
|
+
<li>time - Time of test run in UTC and ISO-8601 format. String.</li>
|
137
|
+
<li>options - Options object as constructed by passed options, superclasses and command line args. Object.</li>
|
138
|
+
<li>io - The class name of the IO object. Will be the string 'STDOUT' if equal to $stdout. String.</li>
|
139
|
+
<li>keys of the options hash, if any. Various key/value pairs.</li>
|
140
|
+
<li>args Array of arguments passed to the program. Array of String.</li>
|
141
|
+
<li>total_count - Total number of tests ran. Integer.</li>
|
142
|
+
</ul></li>
|
143
|
+
<li>statisticsThe accumulated counts for this test run. Object.
|
144
|
+
|
145
|
+
<ul>
|
146
|
+
<li>total Number of total runs. Integer.</li>
|
147
|
+
<li>assertions Count of assertions performed. Integer.</li>
|
148
|
+
<li>failures Number of failed tests. Integer.</li>
|
149
|
+
<li>errors Number of errors encountered. Integer.</li>
|
150
|
+
<li>skips Number of skipped tests. Integer.</li>
|
151
|
+
<li>passes Number of passed tests. Integer.</li>
|
152
|
+
</ul></li>
|
153
|
+
<li>timings Object containing the computed timing information for the entire test run. Object.
|
154
|
+
|
155
|
+
<ul>
|
156
|
+
<li>total_seconds total number of seconds for the entire test run. Float.</li>
|
157
|
+
<li>runs_per_second Averaged number of runs per second. Float.</li>
|
158
|
+
<li>assertions_per_second Averaged number of assertions per second. Float.</li>
|
159
|
+
</ul></li>
|
160
|
+
<li>fails - Array of failed or errored tests. Array of Object.
|
161
|
+
|
162
|
+
<ul>
|
163
|
+
<li>type Type of the failure. Either 'failure' or 'error'. String.</li>
|
164
|
+
<li>classClass name of the test. String.</li>
|
165
|
+
<li>name Name of the test. String.</li>
|
166
|
+
<li>assertions Number of the assertions for this test. Integer.</li>
|
167
|
+
<li>time Time in seconds for this test. Float.</li>
|
168
|
+
<li>message Message reported by this failure or error. String.</li>
|
169
|
+
<li>location File name and line number. file:line. String.</li>
|
170
|
+
<li>backtrace (exists only if type is 'error') Array of backtrace paths and line numbers. Array of String.</li>
|
171
|
+
</ul></li>
|
172
|
+
<li>skips Array of skipped tests. Array of Object.
|
173
|
+
|
174
|
+
<ul>
|
175
|
+
<li>type The string 'skipped'. String.</li>
|
176
|
+
<li>class Class name of the test. String.</li>
|
177
|
+
<li>name The name of the test. String.</li>
|
178
|
+
<li>assertions The count of the assertions for this test. Integer.</li>
|
179
|
+
<li>time The time of this test in seconds. Float.</li>
|
180
|
+
<li>message The message string passed to the 'skip()' method. String.</li>
|
181
|
+
<li>location File name and line number. file:line. String.</li>
|
182
|
+
</ul></li>
|
183
|
+
<li>passes Array of passed test runs. Array of Object.
|
184
|
+
|
185
|
+
<ul>
|
186
|
+
<li>type The string 'passed'. String.</li>
|
187
|
+
<li>class Class name of the test. String.</li>
|
188
|
+
<li>name The name of the test. String.</li>
|
189
|
+
<li>assertions The count of the assertions for this test. Integer.</li>
|
190
|
+
<li>time The time of this test in seconds. Float.</li>
|
191
|
+
</ul></li>
|
192
|
+
</ul>
|
193
|
+
|
194
|
+
<p>The last 2 objects: skips[] and passes[] are absent unless the --verbose command
|
195
|
+
line flag was passed or if the options[:verbose] value is true.</p>
|
128
196
|
|
129
197
|
<h3>Sample output</h3>
|
130
198
|
|
131
199
|
<pre class="code ruby"><code class="ruby"><span class='comment'># Use jq to pretty print the JSON output
|
132
200
|
</span></code></pre>
|
133
201
|
|
202
|
+
<h2>Example analysis feedback</h2>
|
203
|
+
|
204
|
+
<p>JSON can be parsed and manipulated to provide many types of useful information.
|
205
|
+
Below are some example usages.
|
206
|
+
We use the 'jq' program to parse and select and arrange the output.
|
207
|
+
The version of 'jq' is 1.5. It can be downloaded/install instructions here: <a href="https://stedolan.github.io/jq/download/">Download JQ</a>
|
208
|
+
See: <a href="https://stedolan.github.io/jq/manual/">JQ Developer Manual</a></p>
|
209
|
+
|
210
|
+
<h3>Sort by time, slowest first</h3>
|
211
|
+
|
212
|
+
<p>This sort would show you the slowest tests first, getting faster further down the array.
|
213
|
+
Similar to Minitest::Reporters::MeanTimeReporter which produces a report summary showing the slowest running tests.</p>
|
214
|
+
|
215
|
+
<pre class="code ruby"><code class="ruby">$ ruby timings_spec.rb --verbose | jq '.passes | sort_by(.time) | reverse[] | .name, .time'
|
216
|
+
"test_0001_should be slow"
|
217
|
+
5.001584862009622
|
218
|
+
"test_0003_should be slightly faster"
|
219
|
+
1.0003409570199437
|
220
|
+
"test_0002_should be fast"
|
221
|
+
2.9060000088065863e-05
|
222
|
+
</code></pre>
|
223
|
+
|
224
|
+
<h3>Group By Class example</h3>
|
225
|
+
|
226
|
+
<p>Minitest usually runs your tests in a random sequence. This is
|
227
|
+
great for test isolation and to check for state bleed-thru, but can be annoying if trying
|
228
|
+
to determine where similar tests are failing. You can use the jq 'sort_by' or 'group_by' filters to get them back in
|
229
|
+
some semblace of order.</p>
|
230
|
+
|
231
|
+
<p>Here we group the .fails[] array by their class name. (The file: 'group_by_spec.rb'
|
232
|
+
contains 4 tests inside 2 classes.)</p>
|
233
|
+
|
234
|
+
<pre class="code ruby"><code class="ruby">$ ruby group_by_spec.rb |jq '.fails | group_by(.class) | flatten[] | .class, .name'
|
235
|
+
"TestNumericalGroup"
|
236
|
+
"test_4_times_6_equals_24"
|
237
|
+
"TestNumericalGroup"
|
238
|
+
"test_positive_integers_are_greater_than_0"
|
239
|
+
"TestStringGroup"
|
240
|
+
"test_string_is_hello_world"
|
241
|
+
"TestStringGroup"
|
242
|
+
"test_value_length_equals_2"
|
243
|
+
</code></pre>
|
244
|
+
|
245
|
+
<h2>Customizing the JSON format</h2>
|
246
|
+
|
247
|
+
<p>You can adjust the contents of the returned JSON by sub-classing the Minitest::Reporters::JsonReporter class.
|
248
|
+
Override the 'to_h' method and delete or modifythe hash it returns.</p>
|
249
|
+
|
250
|
+
<p>Here is a simple example that eliminates the 'metadata' and 'timmings' components:</p>
|
251
|
+
|
252
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># example spec_helper.rb:
|
253
|
+
</span>
|
254
|
+
<span class='kw'>class</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>SlimJsonReporter</span> <span class='op'><</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>JsonReporter</span>
|
255
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span>
|
256
|
+
<span class='id identifier rubyid_h'>h</span> <span class='op'>=</span> <span class='kw'>super</span>
|
257
|
+
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:metadata</span><span class='rparen'>)</span>
|
258
|
+
<span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:timings</span><span class='rparen'>)</span>
|
259
|
+
<span class='id identifier rubyid_h'>h</span>
|
260
|
+
<span class='kw'>end</span>
|
261
|
+
<span class='kw'>end</span>
|
262
|
+
|
263
|
+
<span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='period'>.</span><span class='id identifier rubyid_use!'>use!</span><span class='lparen'>(</span> <span class='const'>Minitest</span><span class='op'>::</span><span class='const'>Reporters</span><span class='op'>::</span><span class='const'>SlimJsonReporter</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='rparen'>)</span>
|
264
|
+
</code></pre>
|
265
|
+
|
134
266
|
<h2>Contributing</h2>
|
135
267
|
|
136
268
|
<ol>
|
@@ -142,10 +274,27 @@ you will get 2 additional objects: skips[] and passes[]</p>
|
|
142
274
|
</ol>
|
143
275
|
|
144
276
|
<p>Note: Extra credit if git flow feature branching was used.</p>
|
277
|
+
|
278
|
+
<h2>Resources</h2>
|
279
|
+
|
280
|
+
<ul>
|
281
|
+
<li>Code: <a href="https://github.com/edhowland/minitest-reporters-json_reporter">https://github.com/edhowland/minitest-reporters-json_reporter</a></li>
|
282
|
+
<li>Bugs: <a href="https://github.com/edhowland/minitest-reporters-json_reporter/issues">https://github.com/edhowland/minitest-reporters-json_reporter/issues</a></li>
|
283
|
+
<li>Docs: <a href="http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0">http://www.rubydoc.info/gems/minitest-reporters-json_reporter/1.0.0</a></li>
|
284
|
+
<li>Gem: <a href="https://rubygems.org/gems/minitest-reporters-json_reporter">https://rubygems.org/gems/minitest-reporters-json_reporter</a></li>
|
285
|
+
</ul>
|
286
|
+
|
287
|
+
<h6>Feedback</h6>
|
288
|
+
|
289
|
+
<p>If you find this gem helpful, please slip me a note via e-mail: <a href="mailto:ed.howland@gmail.com">ed.howland@gmail.com</a></p>
|
290
|
+
|
291
|
+
<p>I would like to know if anyone has used this approach to interface Minitest to any automated framework or editor.</p>
|
292
|
+
|
293
|
+
<p>Thanks, Ed.</p>
|
145
294
|
</div></div>
|
146
295
|
|
147
296
|
<div id="footer">
|
148
|
-
Generated on
|
297
|
+
Generated on Wed May 25 22:22:25 2016 by
|
149
298
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
150
299
|
0.8.7.6 (ruby-2.2.2).
|
151
300
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Wed May 25 22:22:25 2016 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.6 (ruby-2.2.2).
|
109
109
|
</div>
|
@@ -59,10 +59,10 @@ module Minitest
|
|
59
59
|
##
|
60
60
|
# Create the detail part of the JSON.
|
61
61
|
def detail_h
|
62
|
-
h = { fails:
|
62
|
+
h = { fails: failures_a }
|
63
63
|
if options[:verbose]
|
64
|
-
h[:skips] =
|
65
|
-
h[:passes] =
|
64
|
+
h[:skips] = skips_a
|
65
|
+
h[:passes] = passes_a
|
66
66
|
end
|
67
67
|
h
|
68
68
|
end
|
@@ -150,7 +150,7 @@ module Minitest
|
|
150
150
|
##
|
151
151
|
# Returns the fails array of failure or error hash objects as part of
|
152
152
|
# the output.
|
153
|
-
def
|
153
|
+
def failures_a
|
154
154
|
tests.reject { |e| e.skipped? || e.passed? || e.failure.nil? }
|
155
155
|
.map { |e| failure_h(e) }
|
156
156
|
end
|
@@ -187,7 +187,7 @@ module Minitest
|
|
187
187
|
|
188
188
|
##
|
189
189
|
# Returns the skips[] array object as part of the output.
|
190
|
-
def
|
190
|
+
def skips_a
|
191
191
|
tests.select(&:skipped?).map { |e| skip_h(e) }
|
192
192
|
end
|
193
193
|
|
@@ -202,7 +202,7 @@ module Minitest
|
|
202
202
|
|
203
203
|
##
|
204
204
|
# Returns the passes[] array object as part of the output.
|
205
|
-
def
|
205
|
+
def passes_a
|
206
206
|
tests.select(&:passed?).map { |e| result_h(e, 'passed') }
|
207
207
|
end
|
208
208
|
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
# Must hard code the exact version number because of circular dependency
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'minitest-reporters-json_reporter'
|
8
|
-
spec.version = '0.
|
8
|
+
spec.version = '1.0.0'
|
9
9
|
spec.authors = ['edhowland']
|
10
10
|
spec.email = ['ed.howland@gmail.com']
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-reporters-json_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- edhowland
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-reporters
|