minitest-reporters-json_reporter 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +9 -2
  4. data/Announcement.txt +131 -0
  5. data/README.md +80 -9
  6. data/Rakefile +11 -0
  7. data/doc/Minitest.html +126 -0
  8. data/doc/Minitest/Reporters.html +126 -0
  9. data/doc/Minitest/Reporters/ErrorDetail.html +390 -0
  10. data/doc/Minitest/Reporters/FailDetail.html +248 -0
  11. data/doc/Minitest/Reporters/FaultDetail.html +374 -0
  12. data/doc/Minitest/Reporters/JsonReporter.html +799 -0
  13. data/doc/Minitest/Reporters/PassDetail.html +235 -0
  14. data/doc/Minitest/Reporters/SkipDetail.html +220 -0
  15. data/doc/Minitest/Reporters/TestDetail.html +509 -0
  16. data/doc/_index.html +237 -0
  17. data/doc/class_list.html +58 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +57 -0
  20. data/doc/css/style.css +339 -0
  21. data/doc/file.README.html +142 -0
  22. data/doc/file_list.html +60 -0
  23. data/doc/frames.html +26 -0
  24. data/doc/index.html +142 -0
  25. data/doc/js/app.js +219 -0
  26. data/doc/js/full_list.js +181 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +195 -0
  29. data/doc/top-level-namespace.html +112 -0
  30. data/lib/minitest/reporters/json_reporter.rb +67 -62
  31. data/lib/minitest/reporters/json_reporter/error_detail.rb +25 -0
  32. data/lib/minitest/reporters/json_reporter/fail_detail.rb +16 -0
  33. data/lib/minitest/reporters/json_reporter/fault_detail.rb +39 -0
  34. data/lib/minitest/reporters/json_reporter/pass_detail.rb +16 -0
  35. data/lib/minitest/reporters/json_reporter/skip_detail.rb +16 -0
  36. data/lib/minitest/reporters/json_reporter/test_detail.rb +43 -0
  37. data/lib/minitest/reporters/json_reporter/version.rb +6 -6
  38. data/minitest-reporters-json_reporter.gemspec +3 -2
  39. metadata +35 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94a1de8a674e4127f623f886a6ba0643726d5d86
4
- data.tar.gz: 678bd26a89e8565ec5f1892fbf9d1c8ab65db7c7
3
+ metadata.gz: f5f134ca33ed222b123711da89d4d1a11e7e028a
4
+ data.tar.gz: fc6d7d916c7798d6e091232c382be1a439f31680
5
5
  SHA512:
6
- metadata.gz: 32264e3865b0e4a3c287e96ab466d070c105e081e46847834c8c793062eae47cf45c715630d4fdca7895ec9c80688f0dbac190a186144b3d256c4774bbf5f3e7
7
- data.tar.gz: a43bfb4e853845f1695b13c7877ef0020df3a0ea37bf8908704170c7d2fea69499b56f1ae560b0197afc8df4fc8136bfdc6006b8ed597a41e8a74af655140623
6
+ metadata.gz: 47bcd68180b082db1ba5549fc14929faa540052128b792d6d1673d663cd45e2d245e9bf598962b1645bc09456c7c17b384d4f24f879b986380d76f0fcf4c8069
7
+ data.tar.gz: b3c875b539c0c087ae6f7bb90adc4ebeddb77d7b8efaa38578f4d9ac660765aa09ccbc5ce870eeb4fc3119ea9bb4be608009103f28998f354b743208ecb216ab
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
data/.rubocop.yml CHANGED
@@ -2,14 +2,21 @@
2
2
  Metrics/LineLength:
3
3
  Max: 85
4
4
  Exclude:
5
+ - 'test/**/*'
5
6
  - 'minitest-reporters-json_reporter.gemspec'
6
7
 
7
8
  Style/Documentation:
8
9
  Exclude:
9
10
  - 'spec/**/*'
10
11
  - 'test/**/*'
11
- #Style/Semicolon:
12
- # Exclude:
12
+ Style/Semicolon:
13
+ Exclude:
14
+ - 'test/**/*'
13
15
  # - 'lib/minitest/reporters/json_reporter.rb'
16
+
14
17
  Metrics/ClassLength:
15
18
  Max: 120
19
+
20
+ Style/GlobalVars:
21
+ Exclude:
22
+ - 'test/**/*'
data/Announcement.txt ADDED
@@ -0,0 +1,131 @@
1
+ minitest-reporters-json_reporter version 0.2.0 has been released.
2
+
3
+ Home, Code: https://github.com/edhowland/minitest-reporters-json_reporter
4
+ Bugs: https://github.com/edhowland/minitest-reporters-json_reporter/issues
5
+ Docs:https://github.com/edhowland/minitest-reporters-json_reporter/blob/master/doc/index.html
6
+
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
+
9
+ This version is the preliminary version before doing a PR to the mainline Minitest::Reporters gem.
10
+ It includes a normal unit test in the test folder of the source repository.
11
+ It also includes a customizable output file destination: test/report/json_report.json, some other file or stdout.
12
+ It also includes the passed tests if the --verbose flag is passed.
13
+ It also embeds the backtrace for error fails.
14
+ It also adds parsed command line options to the metadata object.
15
+
16
+ Abstract
17
+
18
+ JSON has become the lingua franca of interprogram communications. There are several very good output formats
19
+ for Minitest, but no JSON format until now. If you want to hook up an IDE or some other automatic
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
21
+ a test run in format like JSON.a test run in an easible consumable format.
22
+
23
+ Anti-features:
24
+
25
+ This version does not include any timing statistics.
26
+ However, you can subclass Minitest::Reporters::JsonReporter and add to the storage accessor any object. This is just a Hash.
27
+ The class is derived from Minitest::StatisticsReporter wherin you can get this detail.
28
+
29
+ Usage is very simple. Just require 'minitest/reporters/json_reporter' in your test_helper.rb or spec_helper.rb.
30
+ 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.
31
+ Here is an example test_helper.rb:
32
+ # ... Other requires
33
+
34
+ require 'minitest/reporters/json_reporter'
35
+ require 'minitest/autorun'
36
+
37
+ Minitest::Reporters.use! [Minitest::Reporters::JsonReporter.new]
38
+ # ...
39
+ # End of test_helper.rb
40
+
41
+ Here is the URLs for the dependent gems:
42
+
43
+ minitest (5.7.0, 5.4.3) : https://rubygems.org/gems/minitest
44
+ minitest-reporters (1.1.8) : https://rubygems.org/gems/minitest-reporters
45
+
46
+ The JSON format is sent to stdout when you run a test or all tests.
47
+ There are 5 (or 6) objects contained within this output:
48
+ The 6th object : passes is only present when --verbose or the options[:verbose] is supplied.
49
+
50
+ 1. status - Status of the overall test run. Can be 'Success', 'Passed with skipped tests' or 'Failed'. There also a color attribute: green, yellow or red - respectfully.
51
+ 2. metadata - General information about this test run. Includes generator name, version and the test run completion time in UTC formatted in ISO8601 format. This also include the parsed command line in the options object.
52
+ 3. statistics - Contains counts of the status of test cases. Includes: Total, Skipped, Failed Errored and Passed.
53
+ 4. 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. Tests that generate an error also contain the filter backtrace.
54
+ 5. skips - Array of each skipped. Each object contains the information as a failed test, including the skip message, if any.
55
+ 6. passes: (Optional: if --verbose is passed to the test): Class name, name and location of the passed test.
56
+
57
+ Here is a sample test run:
58
+ # Pretty up JSON output with jq
59
+ $ cd test/functional
60
+ $ ruby report_spec.rb | jq .
61
+ {
62
+ "status": {
63
+ "code": "Failed",
64
+ "color": "red"
65
+ },
66
+ "metadata": {
67
+ "generated_by": "Minitest::Reporters::JsonReporter",
68
+ "version": "0.2.0",
69
+ "time": "2016-04-21T19:09:34Z",
70
+ "options": {
71
+ "io": "STDOUT",
72
+ "seed": 2579,
73
+ "args": "--seed 2579"
74
+ }
75
+ },
76
+ "statistics": {
77
+ "total": 5,
78
+ "failed": 2,
79
+ "errored": 1,
80
+ "skipped": 1,
81
+ "passed": 1
82
+ },
83
+ "fails": [
84
+ {
85
+ "type": "failure",
86
+ "class": "failure",
87
+ "name": "test_0001_anonymous",
88
+ "message": "Expected: 2\n Actual: 1",
89
+ "location": "report_spec.rb:14"
90
+ },
91
+ {
92
+ "type": "failure",
93
+ "class": "second failure",
94
+ "name": "test_0001_anonymous",
95
+ "message": "Expected: 9\n Actual: 3",
96
+ "location": "report_spec.rb:20"
97
+ },
98
+ {
99
+ "type": "error",
100
+ "class": "Error",
101
+ "name": "test_0001_anonymous",
102
+ "message": "RuntimeError: should fail\n report_spec.rb:6:in `block (2 levels) in <main>'",
103
+ "location": "report_spec.rb:6",
104
+ "backtrace": [
105
+ "report_spec.rb:6:in `block (2 levels) in <main>'"
106
+ ]
107
+ }
108
+ ],
109
+ "skips": [
110
+ {
111
+ "type": "skipped",
112
+ "class": "skipped test",
113
+ "name": "test_0001_anonymous",
114
+ "message": "what a layabout",
115
+ "location": "report_spec.rb:32"
116
+ }
117
+ ]
118
+ }
119
+
120
+ You can use JSON parsing tools to get elements or subsets of this format. One such tool is JQ: https://stedolan.github.io/jq/
121
+
122
+ Here is how you might view only the color of the test:
123
+
124
+ $ ruby blog_test.rb | jq -r .status.color
125
+ green
126
+
127
+ If you find this gem useful, please send me a note about how you are using it.
128
+ I would be interested if you are hooking it up to an automated framework like CI, CD or a code editor or IDE.
129
+ Thanks, Ed
130
+
131
+ Author: Ed Howland email: ed.howland@gmail.com
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # Minitest::Reporters::JsonReporter
2
2
 
3
3
  This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.
4
- You can use this gem to interface MiniTest output into automated tools or IDEs or programmer's editors. An
4
+ You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
5
5
  example interface might be to the Atom editor: [https://atom.io](https://atom.io)
6
- I originally wrote this gem to interface to the Viper audible Programmer's editor for the blind programmer community. See: [https://github.com/edhowland/viper](https://github.com/edhowland/viper)
7
-
8
- ## Version 0.1.1
6
+ 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)
9
7
 
8
+ ## Version 0.2.0
10
9
 
11
10
 
12
11
  ## Installation
@@ -36,17 +35,86 @@ require 'minitest/reporters/json_reporter'
36
35
  In that same file, add something like this near the bottom of the file:
37
36
 
38
37
  ```
39
- MiniTest::Reporters.use! [ MiniTest::Reporters::JsonReporter.new ]
38
+ Minitest::Reporters.use! [ Minitest::Reporters::JsonReporter.new ]
40
39
  ```
41
40
 
42
41
  Then run your tests as normal. You will get a JSON formatted string in stdout.
43
- There are 5 objects contained within this output:
44
42
 
45
- 1. metadata - General information about this test run. Includes generator name, version and the test run completion time in UTC formatted in ISO8601 format.
46
- 2. status - Status of the overall test run. Can be 'Success', 'Passed with skipped tests' or 'Failed'. There also a color attribute: green, yellow or red - respectfully.
43
+ 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.
44
+
45
+ 1. status - Status of the overall test run. Can be 'Success', 'Passed with skipped tests' or 'Failed'. There also a color attribute: green, yellow or red - respectfully.
46
+ 2. 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.
47
47
  3. statistics - Contains counts of the status of test cases. Includes: Total, Skipped, Failed Errored and Passed.
48
- 4. 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.
48
+ 4. 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.
49
49
  5. skips - Array of each skipped. Each object contains the information as a failed test, including the skip message, if any.
50
+ 6. passes - Array of passing tests if the --verbose option was set . This object is normally absent otherwise.
51
+
52
+ Here is a sample output:
53
+
54
+ ```
55
+ # Use jq to pretty print the JSON output
56
+ $ cd test/functional/
57
+ $ ruby report_spec.rb --verbose | jq .
58
+ {
59
+ "status": {
60
+ "code": "Failed",
61
+ "color": "red"
62
+ },
63
+ "metadata": {
64
+ "generated_by": "Minitest::Reporters::JsonReporter",
65
+ "version": "0.2.0",
66
+ "time": "2016-04-21T19:09:34Z",
67
+ "options": {
68
+ "io": "STDOUT",
69
+ "seed": 2579,
70
+ "args": "--seed 2579"
71
+ }
72
+ },
73
+ "statistics": {
74
+ "total": 5,
75
+ "failed": 2,
76
+ "errored": 1,
77
+ "skipped": 1,
78
+ "passed": 1
79
+ },
80
+ "fails": [
81
+ {
82
+ "type": "failure",
83
+ "class": "failure",
84
+ "name": "test_0001_anonymous",
85
+ "message": "Expected: 2\n Actual: 1",
86
+ "location": "report_spec.rb:14"
87
+ },
88
+ {
89
+ "type": "failure",
90
+ "class": "second failure",
91
+ "name": "test_0001_anonymous",
92
+ "message": "Expected: 9\n Actual: 3",
93
+ "location": "report_spec.rb:20"
94
+ },
95
+ {
96
+ "type": "error",
97
+ "class": "Error",
98
+ "name": "test_0001_anonymous",
99
+ "message": "RuntimeError: should fail\n report_spec.rb:6:in `block (2 levels) in <main>'",
100
+ "location": "report_spec.rb:6",
101
+ "backtrace": [
102
+ "report_spec.rb:6:in `block (2 levels) in <main>'"
103
+ ]
104
+ }
105
+ ],
106
+ "skips": [
107
+ {
108
+ "type": "skipped",
109
+ "class": "skipped test",
110
+ "name": "test_0001_anonymous",
111
+ "message": "what a layabout",
112
+ "location": "report_spec.rb:32"
113
+ }
114
+ ]
115
+ }
116
+
117
+ ```
50
118
 
51
119
 
52
120
  ## Contributing
@@ -56,3 +124,6 @@ There are 5 objects contained within this output:
56
124
  3. Commit your changes (`git commit -am 'Add some feature'`)
57
125
  4. Push to the branch (`git push origin my-new-feature`)
58
126
  5. Create a new Pull Request
127
+
128
+ Note: Extra credit if git flow feature branching was used.
129
+
data/Rakefile CHANGED
@@ -1 +1,12 @@
1
+ # Rakefile - tasks for minitest-reporters-json_reporter gem
1
2
  require 'bundler/gem_tasks'
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = './test/*_spec.rb'
8
+ end
9
+
10
+ task :yard do
11
+ sh 'yardoc -o ./doc'
12
+ end
data/doc/Minitest.html ADDED
@@ -0,0 +1,126 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: MiniTest
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!MiniTest.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (M)</a> &raquo;
35
+
36
+
37
+ <span class="title">MiniTest</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: MiniTest
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/minitest/reporters/json_reporter/skip_detail.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+
90
+ <p>MiniTest Namespace for all things Minitest</p>
91
+
92
+
93
+ </div>
94
+ </div>
95
+ <div class="tags">
96
+
97
+
98
+ </div><h2>Defined Under Namespace</h2>
99
+ <p class="children">
100
+
101
+
102
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="MiniTest/Reporters.html" title="MiniTest::Reporters (module)">Reporters</a></span>
103
+
104
+
105
+
106
+
107
+ </p>
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ </div>
118
+
119
+ <div id="footer">
120
+ Generated on Thu Apr 21 20:48:52 2016 by
121
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
+ 0.8.7.6 (ruby-2.2.2).
123
+ </div>
124
+
125
+ </body>
126
+ </html>
@@ -0,0 +1,126 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: MiniTest::Reporters
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!MiniTest/Reporters.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (R)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../MiniTest.html" title="MiniTest (module)">MiniTest</a></span></span>
36
+ &raquo;
37
+ <span class="title">Reporters</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: MiniTest::Reporters
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/minitest/reporters/json_reporter/skip_detail.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+
90
+ <p>Reporters - Extensible reporting framework for Minitest</p>
91
+
92
+
93
+ </div>
94
+ </div>
95
+ <div class="tags">
96
+
97
+
98
+ </div><h2>Defined Under Namespace</h2>
99
+ <p class="children">
100
+
101
+
102
+
103
+
104
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Reporters/SkipDetail.html" title="MiniTest::Reporters::SkipDetail (class)">SkipDetail</a></span>
105
+
106
+
107
+ </p>
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ </div>
118
+
119
+ <div id="footer">
120
+ Generated on Thu Apr 21 20:48:52 2016 by
121
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
+ 0.8.7.6 (ruby-2.2.2).
123
+ </div>
124
+
125
+ </body>
126
+ </html>