minitest-reporters-json_reporter 0.9.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0789166d0fc2d9eb234eea4ce73bd63c29777f8
4
- data.tar.gz: c746180dbe9a3389819b6eee0f5f36cea99a119c
3
+ metadata.gz: 137b4c93b51f77e64563dc73e0fee830b729473f
4
+ data.tar.gz: a0ca90654ccd75f2d10b5ef8fcb85764dca50d1f
5
5
  SHA512:
6
- metadata.gz: 7ddb553f9d9e94b239e5d6655c03b34a27590119b40294b85f036e33149b9329771d8f0f1ed4adf70e70bffcbfe2fce1a85e20e9d34dc802508af2f6e3deb868
7
- data.tar.gz: 7c870a868a1f3badf3c5e1f703efb61e9bbb6dc4bf229d3d5bd5734356a20e8679c56cd08c186feb3f898c9df43c7c004a2946fbd4c9220a610be3e39a1e4629
6
+ metadata.gz: cd1a72b03cd22c919dc614d3431d5489e2b74482fa7b30426d46b0da6f79590bed226281ed6fa79b4a72afc831c1737683c2af8ac68663e2da9775b231affbcc
7
+ data.tar.gz: eee8241a1c266566687ed8594c7b3262819b23db87970fb353c67ea23764a7360d4d341758763bc60ef9c060027be453c379e1f4932186e06f6305c0b1dff56f
@@ -24,5 +24,5 @@ ratings:
24
24
  exclude_paths:
25
25
  - spec/**/*
26
26
  - "**/vendor/**/*"
27
- - "**/docs/**/*"
27
+ - "**/doc/**/*"
28
28
 
@@ -1,21 +1,17 @@
1
- minitest-reporters-json_reporter version 0.9.5 has been released.
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.9.5
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
- Rewritten to be:
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 test_helper.rb or spec_helper.rb.
29
- This gem also depends on 'minitest' and 'minitest/reporters'. Then, you should also invoke the use! method of Minitest::Reporters class with a call to Minitest::Reporters::JsonReporter.new.
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.9.12
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.9.12",
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.9.12](http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.9.5)
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
@@ -119,7 +119,7 @@
119
119
  </div>
120
120
 
121
121
  <div id="footer">
122
- Generated on Tue May 3 20:15:41 2016 by
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>
@@ -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 Tue May 3 20:15:41 2016 by
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'>&#39;</span><span class='tstring_content'>0.2.1</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
137
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>&#39;</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 =&gt; 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 22</span>
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 =&gt; 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 28</span>
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 33</span>
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 Tue May 3 20:15:41 2016 by
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>
@@ -131,7 +131,7 @@
131
131
  </div>
132
132
 
133
133
  <div id="footer">
134
- Generated on Tue May 3 20:15:41 2016 by
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>
@@ -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>[<img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version">][gem]</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
- <h2>Version 0.2.1</h2>
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 &#39;jq sort&#39; 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 &#39;viper_ruby&#39; 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
- <ol>
112
- <li>status - Status of the overall test run. Can be &#39;Success&#39;, &#39;Passed with skipped tests&#39; or &#39;Failed&#39;. There also a color attribute: green, yellow or red - respectfully.</li>
113
- <li>metadata - General information about this test run. Includes generator name, version and the test run completion time in UTC formatted in ISO8601 format. Also include options object computed by super classes including command line arguments.</li>
114
- <li>statistics - Contains the total number of runs, the number of assertions, the number of fails, skips and passes.</li>
115
- <li>Timings - Including total_seconds, runs_per_second and assertions_per_second in float format</li>
116
- <li>fails - Array of failed or errored tests. Each object herein contains the information of each test, its name, class, error message, number of assertions, the timing and location of the test and the filtered backtrace array if an error type.</li>
117
- </ol>
118
-
119
- <h3>Optional objects</h3>
120
-
121
- <p>If the &#39;--verbose&#39; flag was passed on the command line or the options[:verbose] = true was passed to the constructor
122
- you will get 2 additional objects: skips[] and passes[]</p>
123
-
124
- <ol>
125
- <li>skips[] - Information about the skipped test including its message, number of assertions, the time to run the skip and location.</li>
126
- <li>passes[] - Information for all passed test runs including the type, the test name, class, the number of assertions and timing.</li>
127
- </ol>
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 &#39;STDOUT&#39; 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 &#39;failure&#39; or &#39;error&#39;. 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 &#39;error&#39;) 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 &#39;skipped&#39;. 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 &#39;skip()&#39; 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 &#39;passed&#39;. 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 &#39;jq&#39; program to parse and select and arrange the output.
207
+ The version of &#39;jq&#39; 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 &#39;.passes | sort_by(.time) | reverse[] | .name, .time&#39;
216
+ &quot;test_0001_should be slow&quot;
217
+ 5.001584862009622
218
+ &quot;test_0003_should be slightly faster&quot;
219
+ 1.0003409570199437
220
+ &quot;test_0002_should be fast&quot;
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 &#39;sort_by&#39; or &#39;group_by&#39; 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: &#39;group_by_spec.rb&#39;
232
+ contains 4 tests inside 2 classes.)</p>
233
+
234
+ <pre class="code ruby"><code class="ruby">$ ruby group_by_spec.rb |jq &#39;.fails | group_by(.class) | flatten[] | .class, .name&#39;
235
+ &quot;TestNumericalGroup&quot;
236
+ &quot;test_4_times_6_equals_24&quot;
237
+ &quot;TestNumericalGroup&quot;
238
+ &quot;test_positive_integers_are_greater_than_0&quot;
239
+ &quot;TestStringGroup&quot;
240
+ &quot;test_string_is_hello_world&quot;
241
+ &quot;TestStringGroup&quot;
242
+ &quot;test_value_length_equals_2&quot;
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 &#39;to_h&#39; method and delete or modifythe hash it returns.</p>
249
+
250
+ <p>Here is a simple example that eliminates the &#39;metadata&#39; and &#39;timmings&#39; 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'>&lt;</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 Tue May 3 20:15:41 2016 by
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>
@@ -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>[<img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version">][gem]</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
- <h2>Version 0.2.1</h2>
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 &#39;jq sort&#39; 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 &#39;viper_ruby&#39; 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
- <ol>
112
- <li>status - Status of the overall test run. Can be &#39;Success&#39;, &#39;Passed with skipped tests&#39; or &#39;Failed&#39;. There also a color attribute: green, yellow or red - respectfully.</li>
113
- <li>metadata - General information about this test run. Includes generator name, version and the test run completion time in UTC formatted in ISO8601 format. Also include options object computed by super classes including command line arguments.</li>
114
- <li>statistics - Contains the total number of runs, the number of assertions, the number of fails, skips and passes.</li>
115
- <li>Timings - Including total_seconds, runs_per_second and assertions_per_second in float format</li>
116
- <li>fails - Array of failed or errored tests. Each object herein contains the information of each test, its name, class, error message, number of assertions, the timing and location of the test and the filtered backtrace array if an error type.</li>
117
- </ol>
118
-
119
- <h3>Optional objects</h3>
120
-
121
- <p>If the &#39;--verbose&#39; flag was passed on the command line or the options[:verbose] = true was passed to the constructor
122
- you will get 2 additional objects: skips[] and passes[]</p>
123
-
124
- <ol>
125
- <li>skips[] - Information about the skipped test including its message, number of assertions, the time to run the skip and location.</li>
126
- <li>passes[] - Information for all passed test runs including the type, the test name, class, the number of assertions and timing.</li>
127
- </ol>
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 &#39;STDOUT&#39; 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 &#39;failure&#39; or &#39;error&#39;. 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 &#39;error&#39;) 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 &#39;skipped&#39;. 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 &#39;skip()&#39; 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 &#39;passed&#39;. 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 &#39;jq&#39; program to parse and select and arrange the output.
207
+ The version of &#39;jq&#39; 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 &#39;.passes | sort_by(.time) | reverse[] | .name, .time&#39;
216
+ &quot;test_0001_should be slow&quot;
217
+ 5.001584862009622
218
+ &quot;test_0003_should be slightly faster&quot;
219
+ 1.0003409570199437
220
+ &quot;test_0002_should be fast&quot;
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 &#39;sort_by&#39; or &#39;group_by&#39; 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: &#39;group_by_spec.rb&#39;
232
+ contains 4 tests inside 2 classes.)</p>
233
+
234
+ <pre class="code ruby"><code class="ruby">$ ruby group_by_spec.rb |jq &#39;.fails | group_by(.class) | flatten[] | .class, .name&#39;
235
+ &quot;TestNumericalGroup&quot;
236
+ &quot;test_4_times_6_equals_24&quot;
237
+ &quot;TestNumericalGroup&quot;
238
+ &quot;test_positive_integers_are_greater_than_0&quot;
239
+ &quot;TestStringGroup&quot;
240
+ &quot;test_string_is_hello_world&quot;
241
+ &quot;TestStringGroup&quot;
242
+ &quot;test_value_length_equals_2&quot;
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 &#39;to_h&#39; method and delete or modifythe hash it returns.</p>
249
+
250
+ <p>Here is a simple example that eliminates the &#39;metadata&#39; and &#39;timmings&#39; 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'>&lt;</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 Tue May 3 20:15:41 2016 by
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 Tue May 3 20:15:41 2016 by
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: failures_h }
62
+ h = { fails: failures_a }
63
63
  if options[:verbose]
64
- h[:skips] = skips_h
65
- h[:passes] = passes_h
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 failures_h
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 skips_h
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 passes_h
205
+ def passes_a
206
206
  tests.select(&:passed?).map { |e| result_h(e, 'passed') }
207
207
  end
208
208
 
@@ -8,7 +8,7 @@ module Minitest
8
8
  class JsonReporter < BaseReporter
9
9
  ##
10
10
  # Version of the Minitest::Reporters::JsonReporter gem.
11
- VERSION = '0.9.12'.freeze
11
+ VERSION = '1.0.0'.freeze
12
12
  end
13
13
  end
14
14
  end
@@ -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.9.12'
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.9.12
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-24 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters