minitest-reporters-json_reporter 0.2.0 → 0.9.1

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.
data/doc/_index.html CHANGED
@@ -80,43 +80,6 @@
80
80
  <td valign='top' width="33%">
81
81
 
82
82
 
83
- <ul id="alpha_E" class="alpha">
84
- <li class="letter">E</li>
85
- <ul>
86
-
87
- <li>
88
- <span class='object_link'><a href="Minitest/Reporters/ErrorDetail.html" title="Minitest::Reporters::ErrorDetail (class)">ErrorDetail</a></span>
89
-
90
- <small>(Minitest::Reporters)</small>
91
-
92
- </li>
93
-
94
- </ul>
95
- </ul>
96
-
97
-
98
- <ul id="alpha_F" class="alpha">
99
- <li class="letter">F</li>
100
- <ul>
101
-
102
- <li>
103
- <span class='object_link'><a href="Minitest/Reporters/FailDetail.html" title="Minitest::Reporters::FailDetail (class)">FailDetail</a></span>
104
-
105
- <small>(Minitest::Reporters)</small>
106
-
107
- </li>
108
-
109
- <li>
110
- <span class='object_link'><a href="Minitest/Reporters/FaultDetail.html" title="Minitest::Reporters::FaultDetail (class)">FaultDetail</a></span>
111
-
112
- <small>(Minitest::Reporters)</small>
113
-
114
- </li>
115
-
116
- </ul>
117
- </ul>
118
-
119
-
120
83
  <ul id="alpha_J" class="alpha">
121
84
  <li class="letter">J</li>
122
85
  <ul>
@@ -136,11 +99,6 @@
136
99
  <li class="letter">M</li>
137
100
  <ul>
138
101
 
139
- <li>
140
- <span class='object_link'><a href="MiniTest.html" title="MiniTest (module)">MiniTest</a></span>
141
-
142
- </li>
143
-
144
102
  <li>
145
103
  <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span>
146
104
 
@@ -150,21 +108,6 @@
150
108
  </ul>
151
109
 
152
110
 
153
- <ul id="alpha_P" class="alpha">
154
- <li class="letter">P</li>
155
- <ul>
156
-
157
- <li>
158
- <span class='object_link'><a href="Minitest/Reporters/PassDetail.html" title="Minitest::Reporters::PassDetail (class)">PassDetail</a></span>
159
-
160
- <small>(Minitest::Reporters)</small>
161
-
162
- </li>
163
-
164
- </ul>
165
- </ul>
166
-
167
-
168
111
  <ul id="alpha_R" class="alpha">
169
112
  <li class="letter">R</li>
170
113
  <ul>
@@ -176,46 +119,6 @@
176
119
 
177
120
  </li>
178
121
 
179
- <li>
180
- <span class='object_link'><a href="MiniTest/Reporters.html" title="MiniTest::Reporters (module)">Reporters</a></span>
181
-
182
- <small>(MiniTest)</small>
183
-
184
- </li>
185
-
186
- </ul>
187
- </ul>
188
-
189
-
190
- <ul id="alpha_S" class="alpha">
191
- <li class="letter">S</li>
192
- <ul>
193
-
194
- <li>
195
- <span class='object_link'><a href="MiniTest/Reporters/SkipDetail.html" title="MiniTest::Reporters::SkipDetail (class)">SkipDetail</a></span>
196
-
197
- <small>(MiniTest::Reporters)</small>
198
-
199
- </li>
200
-
201
- </ul>
202
- </ul>
203
-
204
-
205
- </td><td valign='top' width="33%">
206
-
207
-
208
- <ul id="alpha_T" class="alpha">
209
- <li class="letter">T</li>
210
- <ul>
211
-
212
- <li>
213
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html" title="Minitest::Reporters::TestDetail (class)">TestDetail</a></span>
214
-
215
- <small>(Minitest::Reporters)</small>
216
-
217
- </li>
218
-
219
122
  </ul>
220
123
  </ul>
221
124
 
@@ -228,7 +131,7 @@
228
131
  </div>
229
132
 
230
133
  <div id="footer">
231
- Generated on Thu Apr 21 20:48:52 2016 by
134
+ Generated on Tue May 3 20:15:41 2016 by
232
135
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
233
136
  0.8.7.6 (ruby-2.2.2).
234
137
  </div>
data/doc/class_list.html CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
  <ul id="full_list" class="class">
52
52
  <li><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></li>
53
- <li><a class='toggle'></a> <span class='object_link'><a href="MiniTest.html" title="MiniTest (module)">MiniTest</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><a class='toggle'></a> <span class='object_link'><a href="MiniTest/Reporters.html" title="MiniTest::Reporters (module)">Reporters</a></span><small class='search_info'>MiniTest</small></li><ul><li><span class='object_link'><a href="MiniTest/Reporters/SkipDetail.html" title="MiniTest::Reporters::SkipDetail (class)">SkipDetail</a></span> &lt; FaultDetail<small class='search_info'>MiniTest::Reporters</small></li></ul></ul><li><a class='toggle'></a> <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><a class='toggle'></a> <span class='object_link'><a href="Minitest/Reporters.html" title="Minitest::Reporters (module)">Reporters</a></span><small class='search_info'>Minitest</small></li><ul><li><span class='object_link'><a href="Minitest/Reporters/ErrorDetail.html" title="Minitest::Reporters::ErrorDetail (class)">ErrorDetail</a></span> &lt; FaultDetail<small class='search_info'>Minitest::Reporters</small></li><li><span class='object_link'><a href="Minitest/Reporters/FailDetail.html" title="Minitest::Reporters::FailDetail (class)">FailDetail</a></span> &lt; FaultDetail<small class='search_info'>Minitest::Reporters</small></li><li><span class='object_link'><a href="Minitest/Reporters/FaultDetail.html" title="Minitest::Reporters::FaultDetail (class)">FaultDetail</a></span> &lt; TestDetail<small class='search_info'>Minitest::Reporters</small></li><li><span class='object_link'><a href="Minitest/Reporters/JsonReporter.html" title="Minitest::Reporters::JsonReporter (class)">JsonReporter</a></span> &lt; BaseReporter<small class='search_info'>Minitest::Reporters</small></li><li><span class='object_link'><a href="Minitest/Reporters/PassDetail.html" title="Minitest::Reporters::PassDetail (class)">PassDetail</a></span> &lt; TestDetail<small class='search_info'>Minitest::Reporters</small></li><li><span class='object_link'><a href="Minitest/Reporters/TestDetail.html" title="Minitest::Reporters::TestDetail (class)">TestDetail</a></span> &lt; Object<small class='search_info'>Minitest::Reporters</small></li></ul></ul>
53
+ <li><a class='toggle'></a> <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><a class='toggle'></a> <span class='object_link'><a href="Minitest/Reporters.html" title="Minitest::Reporters (module)">Reporters</a></span><small class='search_info'>Minitest</small></li><ul><li><span class='object_link'><a href="Minitest/Reporters/JsonReporter.html" title="Minitest::Reporters::JsonReporter (class)">JsonReporter</a></span> &lt; BaseReporter<small class='search_info'>Minitest::Reporters</small></li></ul></ul>
54
54
 
55
55
  </ul>
56
56
  </div>
data/doc/file.README.html CHANGED
@@ -63,12 +63,17 @@
63
63
 
64
64
  <div id="content"><div id='filecontents'><h1>Minitest::Reporters::JsonReporter</h1>
65
65
 
66
- <p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.
67
- You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
66
+ <p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.</p>
67
+
68
+ <p>[<img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version">][gem]</p>
69
+
70
+ <h2>Abstract</h2>
71
+
72
+ <p>You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
68
73
  example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a>
69
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>
70
75
 
71
- <h2>Version 0.2.0</h2>
76
+ <h2>Version 0.2.1</h2>
72
77
 
73
78
  <h2>Installation</h2>
74
79
 
@@ -101,18 +106,27 @@ I originally wrote this gem to interface to the Viper audible code editor for t
101
106
 
102
107
  <p>Then run your tests as normal. You will get a JSON formatted string in stdout.</p>
103
108
 
104
- <p>There are 5 or 6 objects contained within this output: The 6th object: passes is only included if the --verbose option was passed to the test or set in the options parameter to the constructor.</p>
109
+ <h2>Object Summary</h2>
105
110
 
106
111
  <ol>
107
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>
108
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>
109
- <li>statistics - Contains counts of the status of test cases. Includes: Total, Skipped, Failed Errored and Passed.</li>
110
- <li>fails - Array of failed or errored tests. Each object herein contains the information of each test, its name, class, error message and location of the test and the filtered backtrace array if an error type.</li>
111
- <li>skips - Array of each skipped. Each object contains the information as a failed test, including the skip message, if any.</li>
112
- <li>passes - Array of passing tests if the --verbose option was set . This object is normally absent otherwise.</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>
113
117
  </ol>
114
118
 
115
- <p>Here is a sample output:</p>
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>
128
+
129
+ <h3>Sample output</h3>
116
130
 
117
131
  <pre class="code ruby"><code class="ruby"><span class='comment'># Use jq to pretty print the JSON output
118
132
  </span></code></pre>
@@ -128,12 +142,10 @@ I originally wrote this gem to interface to the Viper audible code editor for t
128
142
  </ol>
129
143
 
130
144
  <p>Note: Extra credit if git flow feature branching was used.</p>
131
-
132
- <p>^.</p>
133
145
  </div></div>
134
146
 
135
147
  <div id="footer">
136
- Generated on Thu Apr 21 20:48:52 2016 by
148
+ Generated on Tue May 3 20:15:41 2016 by
137
149
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
150
  0.8.7.6 (ruby-2.2.2).
139
151
  </div>
data/doc/index.html CHANGED
@@ -63,12 +63,17 @@
63
63
 
64
64
  <div id="content"><div id='filecontents'><h1>Minitest::Reporters::JsonReporter</h1>
65
65
 
66
- <p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.
67
- You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
66
+ <p>This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.</p>
67
+
68
+ <p>[<img src="https://badge.fury.io/rb/minitest-reporters-json_reporter.svg" alt="Gem Version">][gem]</p>
69
+
70
+ <h2>Abstract</h2>
71
+
72
+ <p>You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
68
73
  example interface might be to the Atom editor: <a href="https://atom.io">https://atom.io</a>
69
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>
70
75
 
71
- <h2>Version 0.2.0</h2>
76
+ <h2>Version 0.2.1</h2>
72
77
 
73
78
  <h2>Installation</h2>
74
79
 
@@ -101,18 +106,27 @@ I originally wrote this gem to interface to the Viper audible code editor for t
101
106
 
102
107
  <p>Then run your tests as normal. You will get a JSON formatted string in stdout.</p>
103
108
 
104
- <p>There are 5 or 6 objects contained within this output: The 6th object: passes is only included if the --verbose option was passed to the test or set in the options parameter to the constructor.</p>
109
+ <h2>Object Summary</h2>
105
110
 
106
111
  <ol>
107
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>
108
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>
109
- <li>statistics - Contains counts of the status of test cases. Includes: Total, Skipped, Failed Errored and Passed.</li>
110
- <li>fails - Array of failed or errored tests. Each object herein contains the information of each test, its name, class, error message and location of the test and the filtered backtrace array if an error type.</li>
111
- <li>skips - Array of each skipped. Each object contains the information as a failed test, including the skip message, if any.</li>
112
- <li>passes - Array of passing tests if the --verbose option was set . This object is normally absent otherwise.</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>
113
117
  </ol>
114
118
 
115
- <p>Here is a sample output:</p>
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>
128
+
129
+ <h3>Sample output</h3>
116
130
 
117
131
  <pre class="code ruby"><code class="ruby"><span class='comment'># Use jq to pretty print the JSON output
118
132
  </span></code></pre>
@@ -128,12 +142,10 @@ I originally wrote this gem to interface to the Viper audible code editor for t
128
142
  </ol>
129
143
 
130
144
  <p>Note: Extra credit if git flow feature branching was used.</p>
131
-
132
- <p>^.</p>
133
145
  </div></div>
134
146
 
135
147
  <div id="footer">
136
- Generated on Thu Apr 21 20:48:52 2016 by
148
+ Generated on Tue May 3 20:15:41 2016 by
137
149
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
150
  0.8.7.6 (ruby-2.2.2).
139
151
  </div>
data/doc/method_list.html CHANGED
@@ -52,139 +52,19 @@
52
52
 
53
53
 
54
54
  <li class="r1 ">
55
- <span class='object_link'><a href="Minitest/Reporters/ErrorDetail.html#backtrace-instance_method" title="Minitest::Reporters::ErrorDetail#backtrace (method)">#backtrace</a></span>
56
- <small>Minitest::Reporters::ErrorDetail</small>
57
- </li>
58
-
59
-
60
- <li class="r2 ">
61
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#green%3F-instance_method" title="Minitest::Reporters::JsonReporter#green? (method)">#green?</a></span>
62
- <small>Minitest::Reporters::JsonReporter</small>
63
- </li>
64
-
65
-
66
- <li class="r1 ">
67
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#init_status-instance_method" title="Minitest::Reporters::JsonReporter#init_status (method)">#init_status</a></span>
68
- <small>Minitest::Reporters::JsonReporter</small>
69
- </li>
70
-
71
-
72
- <li class="r2 ">
73
55
  <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#initialize-instance_method" title="Minitest::Reporters::JsonReporter#initialize (method)">#initialize</a></span>
74
56
  <small>Minitest::Reporters::JsonReporter</small>
75
57
  </li>
76
58
 
77
59
 
78
- <li class="r1 ">
79
- <span class='object_link'><a href="Minitest/Reporters/FailDetail.html#initialize-instance_method" title="Minitest::Reporters::FailDetail#initialize (method)">#initialize</a></span>
80
- <small>Minitest::Reporters::FailDetail</small>
81
- </li>
82
-
83
-
84
- <li class="r2 ">
85
- <span class='object_link'><a href="Minitest/Reporters/PassDetail.html#initialize-instance_method" title="Minitest::Reporters::PassDetail#initialize (method)">#initialize</a></span>
86
- <small>Minitest::Reporters::PassDetail</small>
87
- </li>
88
-
89
-
90
- <li class="r1 ">
91
- <span class='object_link'><a href="MiniTest/Reporters/SkipDetail.html#initialize-instance_method" title="MiniTest::Reporters::SkipDetail#initialize (method)">#initialize</a></span>
92
- <small>MiniTest::Reporters::SkipDetail</small>
93
- </li>
94
-
95
-
96
- <li class="r2 ">
97
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html#initialize-instance_method" title="Minitest::Reporters::TestDetail#initialize (method)">#initialize</a></span>
98
- <small>Minitest::Reporters::TestDetail</small>
99
- </li>
100
-
101
-
102
- <li class="r1 ">
103
- <span class='object_link'><a href="Minitest/Reporters/ErrorDetail.html#initialize-instance_method" title="Minitest::Reporters::ErrorDetail#initialize (method)">#initialize</a></span>
104
- <small>Minitest::Reporters::ErrorDetail</small>
105
- </li>
106
-
107
-
108
- <li class="r2 ">
109
- <span class='object_link'><a href="Minitest/Reporters/FaultDetail.html#initialize-instance_method" title="Minitest::Reporters::FaultDetail#initialize (method)">#initialize</a></span>
110
- <small>Minitest::Reporters::FaultDetail</small>
111
- </li>
112
-
113
-
114
- <li class="r1 ">
115
- <span class='object_link'><a href="Minitest/Reporters/FaultDetail.html#location-instance_method" title="Minitest::Reporters::FaultDetail#location (method)">#location</a></span>
116
- <small>Minitest::Reporters::FaultDetail</small>
117
- </li>
118
-
119
-
120
- <li class="r2 ">
121
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#metadata_h-instance_method" title="Minitest::Reporters::JsonReporter#metadata_h (method)">#metadata_h</a></span>
122
- <small>Minitest::Reporters::JsonReporter</small>
123
- </li>
124
-
125
-
126
- <li class="r1 ">
127
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html#predicate-instance_method" title="Minitest::Reporters::TestDetail#predicate (method)">#predicate</a></span>
128
- <small>Minitest::Reporters::TestDetail</small>
129
- </li>
130
-
131
-
132
- <li class="r2 ">
133
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html#query-instance_method" title="Minitest::Reporters::TestDetail#query (method)">#query</a></span>
134
- <small>Minitest::Reporters::TestDetail</small>
135
- </li>
136
-
137
-
138
- <li class="r1 ">
139
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#record-instance_method" title="Minitest::Reporters::JsonReporter#record (method)">#record</a></span>
140
- <small>Minitest::Reporters::JsonReporter</small>
141
- </li>
142
-
143
-
144
60
  <li class="r2 ">
145
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#red%3F-instance_method" title="Minitest::Reporters::JsonReporter#red? (method)">#red?</a></span>
146
- <small>Minitest::Reporters::JsonReporter</small>
147
- </li>
148
-
149
-
150
- <li class="r1 ">
151
61
  <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#report-instance_method" title="Minitest::Reporters::JsonReporter#report (method)">#report</a></span>
152
62
  <small>Minitest::Reporters::JsonReporter</small>
153
63
  </li>
154
64
 
155
65
 
156
- <li class="r2 ">
157
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#storage-instance_method" title="Minitest::Reporters::JsonReporter#storage (method)">#storage</a></span>
158
- <small>Minitest::Reporters::JsonReporter</small>
159
- </li>
160
-
161
-
162
- <li class="r1 ">
163
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html#test_obj-instance_method" title="Minitest::Reporters::TestDetail#test_obj (method)">#test_obj</a></span>
164
- <small>Minitest::Reporters::TestDetail</small>
165
- </li>
166
-
167
-
168
- <li class="r2 ">
169
- <span class='object_link'><a href="Minitest/Reporters/TestDetail.html#to_h-instance_method" title="Minitest::Reporters::TestDetail#to_h (method)">#to_h</a></span>
170
- <small>Minitest::Reporters::TestDetail</small>
171
- </li>
172
-
173
-
174
66
  <li class="r1 ">
175
- <span class='object_link'><a href="Minitest/Reporters/ErrorDetail.html#to_h-instance_method" title="Minitest::Reporters::ErrorDetail#to_h (method)">#to_h</a></span>
176
- <small>Minitest::Reporters::ErrorDetail</small>
177
- </li>
178
-
179
-
180
- <li class="r2 ">
181
- <span class='object_link'><a href="Minitest/Reporters/FaultDetail.html#to_h-instance_method" title="Minitest::Reporters::FaultDetail#to_h (method)">#to_h</a></span>
182
- <small>Minitest::Reporters::FaultDetail</small>
183
- </li>
184
-
185
-
186
- <li class="r1 ">
187
- <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#yellow%3F-instance_method" title="Minitest::Reporters::JsonReporter#yellow? (method)">#yellow?</a></span>
67
+ <span class='object_link'><a href="Minitest/Reporters/JsonReporter.html#storage-instance_method" title="Minitest::Reporters::JsonReporter#storage (method)">#storage</a></span>
188
68
  <small>Minitest::Reporters::JsonReporter</small>
189
69
  </li>
190
70
 
@@ -85,7 +85,7 @@
85
85
  <p class="children">
86
86
 
87
87
 
88
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="MiniTest.html" title="MiniTest (module)">MiniTest</a></span>, <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span>
88
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span>
89
89
 
90
90
 
91
91
 
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Thu Apr 21 20:48:52 2016 by
106
+ Generated on Tue May 3 20:15:41 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>
@@ -2,164 +2,202 @@
2
2
 
3
3
  require 'json'
4
4
  require 'time'
5
+
5
6
  require 'minitest'
6
7
  require 'minitest/reporters'
7
8
 
8
9
  require_relative 'json_reporter/version'
9
- require_relative 'json_reporter/test_detail'
10
- require_relative 'json_reporter/pass_detail'
11
- require_relative 'json_reporter/fault_detail'
12
- require_relative 'json_reporter/skip_detail'
13
- require_relative 'json_reporter/error_detail'
14
- require_relative 'json_reporter/fail_detail'
15
-
16
10
  # Minitest namespace - plugins must live here
17
11
  module Minitest
18
12
  # Minitest::Reporters from minitest-reporters gem: See: https://github.com/kern/minitest-reporters
19
13
  module Reporters
20
- # Minitest Reporter that produces a JSON output for interface in IDEs, editor
14
+ ##
15
+ # Minitest Reporter that produces a JSON output for interface in
16
+ # IDEs, CD/CI tools and codeeditors
21
17
  class JsonReporter < BaseReporter
22
- def initialize(my_options = {})
23
- super my_options
24
- @skipped = 0
25
- @failed = 0
26
- @errored = 0
27
- @passed = 0
28
- @storage = init_status
18
+ ##
19
+ # Constructor for Minitest::Reporters::JsonReporter
20
+ # Takes possible options. E.g. :verbose => true
21
+ def initialize(options = {})
22
+ super
29
23
  end
30
24
 
31
- attr_reader :storage
25
+ ##
26
+ # Hash that represents the final elements prior to being converted to JSON
27
+ attr_accessor :storage
32
28
 
33
- def metadata_h
34
- {
35
- generated_by: self.class.name,
36
- version: Minitest::Reporters::JsonReporter::VERSION,
37
- time: Time.now.utc.iso8601
38
- }
29
+ ##
30
+ # Called by runner to report the conclusion of the test run
31
+ # Converts result of to_h to JSON and calls io.write to output it.
32
+ def report
33
+ super
34
+
35
+ @storage = to_h
36
+ # formate @storage as JSON and write to output stream
37
+ io.write(JSON.dump(@storage))
38
+ end
39
+
40
+ protected
41
+
42
+ ##
43
+ # Convert summary and detail to hash
44
+ def to_h
45
+ summary_h.merge(detail_h)
39
46
  end
40
47
 
41
- def init_status
48
+ ##
49
+ # Create the summary part of the JSON
50
+ def summary_h
42
51
  {
43
- status: green_status,
52
+ status: status_h,
44
53
  metadata: metadata_h,
45
54
  statistics: statistics_h,
46
- fails: [],
47
- skips: []
55
+ timings: timings_h
48
56
  }
49
57
  end
50
58
 
51
- def record(test)
52
- super
53
- skipped(test) || errored(test) || failed(test) || passed(test)
59
+ ##
60
+ # Create the detail part of the JSON.
61
+ def detail_h
62
+ h = { fails: failures_h }
63
+ if options[:verbose]
64
+ h[:skips] = skips_h
65
+ h[:passes] = passes_h
66
+ end
67
+ h
54
68
  end
55
69
 
56
- def report
57
- super
58
-
59
- set_status # sets the success or failure and color in the status object
60
- # options only exists once test run starts
61
- @storage[:metadata][:options] = transform_store(options)
62
- @storage[:statistics] = statistics_h
63
- # Only add this if not already added and verbose option is set
64
- @storage[:passes] ||= [] if options[:verbose]
65
-
66
- io.write(JSON.dump(@storage))
70
+ def status_h
71
+ {
72
+ code: ['Failed', 'Passed with skipped tests', 'Success'][color_i],
73
+ color: %w(red yellow green)[color_i]
74
+ }.merge(extra_message_h)
75
+ end
76
+
77
+ ##
78
+ # return index corresponding to red, yellow or green
79
+ # if errors or failures, skips or passes (default)
80
+ def color_i
81
+ if (failures + errors) > 0
82
+ 0
83
+ elsif skips > 0
84
+ 1
85
+ else
86
+ 2
87
+ end
67
88
  end
68
89
 
69
- def yellow?
70
- @skipped > 0 && !red?
90
+ ##
91
+ # return a hash with status:message if skips > 0 and no verboseoption
92
+ def extra_message_h
93
+ if !options[:verbose] && skips > 0
94
+ { message:
95
+ 'You have skipped tests. Run with --verbose for details.' }
96
+ else
97
+ {}
98
+ end
71
99
  end
72
100
 
73
- def green?
74
- !red? && !yellow?
101
+ def metadata_h
102
+ {
103
+ generated_by: self.class.name,
104
+ version: Minitest::Reporters::JsonReporter::VERSION,
105
+ ruby_version: RUBY_VERSION,
106
+ ruby_patchlevel: RUBY_PATCHLEVEL,
107
+ ruby_platform: RUBY_PLATFORM,
108
+ time: Time.now.utc.iso8601,
109
+ options: transform(options)
110
+ }
75
111
  end
76
112
 
77
- def red?
78
- @failed + @errored > 0
113
+ def transform(opts)
114
+ o = opts.clone
115
+ o[:io] = o[:io].class.name
116
+ o[:io] = 'STDOUT' if opts[:io] == $stdout
117
+ o
79
118
  end
80
119
 
81
- private
120
+ def statistics_h
121
+ {
122
+ total: count,
123
+ assertions: assertions,
124
+ failures: failures,
125
+ errors: errors,
126
+ skips: skips,
127
+ passes: (count - (failures + errors + skips))
128
+ }
129
+ end
82
130
 
83
- def set_status
84
- @storage[:status] = if red?
85
- red_status
86
- elsif yellow?
87
- yellow_status
88
- else
89
- green_status
90
- end
131
+ def timings_h
132
+ {
133
+ total_seconds: total_time,
134
+ runs_per_second: count / total_time,
135
+ assertions_per_second: assertions / total_time
136
+ }
91
137
  end
92
138
 
93
- def color_h(code, color)
94
- { code: code, color: color }
139
+ def failures_h
140
+ tests.reject { |e| e.skipped? || e.passed? || e.failure.nil? }
141
+ .map { |e| failure_h(e) }
95
142
  end
96
143
 
97
- def red_status
98
- color_h('Failed', 'red')
144
+ def failure_h(result)
145
+ if result.error?
146
+ error_h(result)
147
+ else
148
+ failed_h(result)
149
+ end
99
150
  end
100
151
 
101
- def yellow_status
102
- color_h('Passed, with skipped tests', 'yellow')
152
+ def error_h(result)
153
+ h = result_h(result, 'error')
154
+ h[:message] = result.failure.message
155
+ h[:location] = location(result.failure)
156
+ h[:backtrace] = filter_backtrace(result.failure.backtrace)
157
+ h
103
158
  end
104
159
 
105
- def green_status
106
- color_h('Success', 'green')
160
+ def failed_h(result)
161
+ h = result_h(result, 'failed')
162
+ h[:message] = result.failure.message
163
+ h[:location] = location(result.failure)
164
+ h
107
165
  end
108
166
 
109
- def statistics_h
110
- {
111
- total: @failed + @errored + @skipped + @passed,
112
- failed: @failed,
113
- errored: @errored,
114
- skipped: @skipped,
115
- passed: @passed
116
- }
167
+ def skips_h
168
+ tests.select(&:skipped?).map { |e| skip_h(e) }
117
169
  end
118
170
 
119
- def skipped(test)
120
- Minitest::Reporters::SkipDetail.new(test).query do |d|
121
- @skipped += 1
122
- @storage[:skips] << d.to_h
123
- end
171
+ def skip_h(result)
172
+ h = result_h(result, 'skipped')
173
+ h[:message] = result.failure.message
174
+ h[:location] = location(result.failure)
175
+ h
124
176
  end
125
177
 
126
- def errored(test)
127
- Minitest::Reporters::ErrorDetail.new(test).query do |d|
128
- d.backtrace = filter_backtrace(d.backtrace)
129
- @storage[:fails] << d.to_h
130
- @errored += 1
131
- end
178
+ def passes_h
179
+ tests.select(&:passed?).map { |e| result_h(e, 'passed') }
132
180
  end
133
181
 
134
- def failed(test)
135
- Minitest::Reporters::FailDetail.new(test).query do |d|
136
- @storage[:fails] << d.to_h
137
- @failed += 1
138
- end
182
+ def result_h(result, type)
183
+ {
184
+ type: type,
185
+ class: result.class.name,
186
+ name: result.name,
187
+ assertions: result.assertions,
188
+ time: result.time
189
+ }
139
190
  end
140
191
 
141
- # If it is increments @passed and optionally adds PassDetail object
142
- # to .passes array
143
- # if options[:verbose] == true
144
- def passed(test)
145
- Minitest::Reporters::PassDetail.new(test).query do |d|
146
- @passed += 1
147
- if options[:verbose]
148
- @storage[:passes] ||= []
149
- @storage[:passes] << d.to_h
150
- end
192
+ def location(exception)
193
+ last_before_assertion = ''
194
+
195
+ exception.backtrace.reverse_each do |s|
196
+ break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
197
+ last_before_assertion = s
151
198
  end
152
- end
153
199
 
154
- # transform_store options: make pretty object for our JSON [metadata.options]
155
- # If :io is the IO class and == $stdout: "STDOUT"
156
- # Delete key: total_count
157
- def transform_store(opts)
158
- o = opts.clone
159
- o[:io] = o[:io].class.name
160
- o[:io] = 'STDOUT' if opts[:io] == $stdout
161
- o.delete(:total_count)
162
- o
200
+ last_before_assertion.sub(/:in .*$/, '')
163
201
  end
164
202
  end
165
203
  end