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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b91b566809b95993d90be26881a2b7301965f4b
4
- data.tar.gz: d3dbd54d0b1811587bfa6f8298a64e933a429e18
3
+ metadata.gz: 63ad9b8208797db4a67cc3f5b6e4fbe9ee72354e
4
+ data.tar.gz: 140071441091a74338f713e6ddf18f76ddcba257
5
5
  SHA512:
6
- metadata.gz: 788bc66cc5ce34ae8fa1944e59299d38d072039dae2ef36ea8938e5eb4bdbf8364a861c6c5ed252add21f23598fd3fb1207022fdcdfa892b4876226629886c98
7
- data.tar.gz: 26ebf4dbd2d4dfcdbcf0bee8f63dd5aff2fab5d20bea5468b6e6e5fdb2b6e130206993cb8fc739b147652b5ee6ef318733dfd9127da82bd442f653cf3d32d921
6
+ metadata.gz: aa6c42c6cce9aac13de22fa266e8ad84bc010fb2b8e6a716d067c4f59ec46512254176db60944d84846142b2121b4fa5ee237c2267cf1b797ab6751a79438afe
7
+ data.tar.gz: 8c2364f6479c554fc4d42bf5dfe77b674104ba714834f14929379c48056fa1d9ee1d34dc03fb80cd4090061369f39b5867900ed9ab6b952157e2fed1e4740caf
data/README.md CHANGED
@@ -24,6 +24,7 @@ Or install it yourself as:
24
24
  Known extensions: junit, ...
25
25
  --junit Generate a junit xml report
26
26
  --junit-filename=OUT Target output filename. Defaults to report.xml
27
+ --junit-jenkins Sanitize test names for Jenkins display
27
28
  ...
28
29
 
29
30
  ## Contributing
data/Rakefile CHANGED
@@ -6,4 +6,5 @@ RuboCop::RakeTask.new
6
6
 
7
7
  Rake::TestTask.new do |t|
8
8
  t.test_files = FileList['test/*_test.rb']
9
+ t.options = '--junit --junit-jenkins' if ENV['CI']
9
10
  end
@@ -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
- result.class.to_s.gsub(/(.*)::(.*)/, '\1.\2')
60
- result.class
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
@@ -1,6 +1,6 @@
1
1
  module Minitest
2
2
  # :nodoc:
3
3
  module Junit
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  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[:junit]
17
- file_klass = options[:file_klass] || File
18
- io = file_klass.new options[:junit_filename] || 'report.xml', 'w'
19
- reporter << Junit::Reporter.new(io) if options[:junit]
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
@@ -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
@@ -31,7 +31,7 @@ class ReporterTest < Minitest::Test
31
31
 
32
32
  def create_reporter
33
33
  io = StringIO.new
34
- reporter = Minitest::Junit::Reporter.new io
34
+ reporter = Minitest::Junit::Reporter.new io, {}
35
35
  def reporter.output
36
36
  @io.string
37
37
  end
@@ -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.new 'passing test'
58
- def test.class
59
- 'ATestClass'
60
- end
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.1.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 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest