minitest-junit 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -0
- data/lib/minitest/junit.rb +7 -4
- data/lib/minitest/junit/version.rb +1 -1
- data/lib/minitest/junit_plugin.rb +7 -4
- data/test/junit_plugin_test.rb +8 -0
- data/test/reporter_test.rb +1 -1
- data/test/testcase_formatter_test.rb +18 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63ad9b8208797db4a67cc3f5b6e4fbe9ee72354e
|
4
|
+
data.tar.gz: 140071441091a74338f713e6ddf18f76ddcba257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa6c42c6cce9aac13de22fa266e8ad84bc010fb2b8e6a716d067c4f59ec46512254176db60944d84846142b2121b4fa5ee237c2267cf1b797ab6751a79438afe
|
7
|
+
data.tar.gz: 8c2364f6479c554fc4d42bf5dfe77b674104ba714834f14929379c48056fa1d9ee1d34dc03fb80cd4090061369f39b5867900ed9ab6b952157e2fed1e4740caf
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/minitest/junit.rb
CHANGED
@@ -7,9 +7,10 @@ module Minitest
|
|
7
7
|
module Junit
|
8
8
|
# :nodoc:
|
9
9
|
class Reporter
|
10
|
-
def initialize(io)
|
10
|
+
def initialize(io, options)
|
11
11
|
@io = io
|
12
12
|
@results = []
|
13
|
+
@options = options
|
13
14
|
end
|
14
15
|
|
15
16
|
def passed?
|
@@ -56,12 +57,14 @@ module Minitest
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def format_class(result)
|
59
|
-
|
60
|
-
|
60
|
+
if @options[:junit_jenkins]
|
61
|
+
result.class.to_s.gsub(/(.*)::(.*)/, '\1.\2')
|
62
|
+
else
|
63
|
+
result.class
|
64
|
+
end
|
61
65
|
end
|
62
66
|
|
63
67
|
def format_name(result)
|
64
|
-
result.name.sub(/^test_/, '').gsub('_', ' ')
|
65
68
|
result.name
|
66
69
|
end
|
67
70
|
end
|
@@ -10,12 +10,15 @@ module Minitest
|
|
10
10
|
' Defaults to report.xml' do |out|
|
11
11
|
options[:junit_filename] = out
|
12
12
|
end
|
13
|
+
opts.on '--junit-jenkins', 'Sanitize test names for Jenkins display' do
|
14
|
+
options[:junit_jenkins] = true
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.plugin_junit_init(options)
|
16
|
-
return unless options
|
17
|
-
file_klass = options
|
18
|
-
io = file_klass.new options
|
19
|
-
reporter << Junit::Reporter.new(io
|
19
|
+
return unless options.delete :junit
|
20
|
+
file_klass = options.delete(:file_klass) || File
|
21
|
+
io = file_klass.new options.delete(:junit_filename) || 'report.xml', 'w'
|
22
|
+
reporter << Junit::Reporter.new(io, options)
|
20
23
|
end
|
21
24
|
end
|
data/test/junit_plugin_test.rb
CHANGED
@@ -72,4 +72,12 @@ class PluginTest < Minitest::Test
|
|
72
72
|
|
73
73
|
assert_equal 'somefile.xml', options[:junit_filename]
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_jenkins_sanitization_is_specified_by_a_flag
|
77
|
+
opts = OptionParser.new
|
78
|
+
options = {}
|
79
|
+
Minitest.plugin_junit_options opts, options
|
80
|
+
opts.parse('--junit-jenkins')
|
81
|
+
assert options[:junit_jenkins]
|
82
|
+
end
|
75
83
|
end
|
data/test/reporter_test.rb
CHANGED
@@ -45,6 +45,16 @@ class TestCaseFormatter < Minitest::Test
|
|
45
45
|
assert_match(/<error/, reporter.output)
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_jenkins_sanitizer_uses_modules_as_packages
|
49
|
+
test = create_test_result 'FirstModule::SecondModule::TestClass'
|
50
|
+
reporter = create_reporter junit_jenkins: true
|
51
|
+
reporter.record test
|
52
|
+
|
53
|
+
reporter.report
|
54
|
+
|
55
|
+
assert_match 'FirstModule::SecondModule.TestClass', reporter.output
|
56
|
+
end
|
57
|
+
|
48
58
|
private
|
49
59
|
|
50
60
|
def create_error(klass)
|
@@ -53,11 +63,12 @@ class TestCaseFormatter < Minitest::Test
|
|
53
63
|
e
|
54
64
|
end
|
55
65
|
|
56
|
-
def create_test_result
|
57
|
-
test = Minitest::Test
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
def create_test_result(name = 'ATestClass')
|
67
|
+
test = Class.new Minitest::Test do
|
68
|
+
define_method 'class' do
|
69
|
+
name
|
70
|
+
end
|
71
|
+
end.new 'test_method_name'
|
61
72
|
test.time = a_number
|
62
73
|
test.assertions = a_number
|
63
74
|
test
|
@@ -67,9 +78,9 @@ class TestCaseFormatter < Minitest::Test
|
|
67
78
|
rand(100)
|
68
79
|
end
|
69
80
|
|
70
|
-
def create_reporter
|
81
|
+
def create_reporter(options = {})
|
71
82
|
io = StringIO.new ''
|
72
|
-
reporter = Minitest::Junit::Reporter.new io
|
83
|
+
reporter = Minitest::Junit::Reporter.new io, options
|
73
84
|
def reporter.output
|
74
85
|
@io.string
|
75
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-junit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allan Espinosa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|