minitest-junit 2.0.0 → 2.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 518beb2f7cb77d8e953d77f9b4342c5ec1d20603b8807782f71305b58a0f985d
4
- data.tar.gz: d3dec1da3aa864c7e92a80628353e24c75a465df90d7e60fddb134a1dc725d89
3
+ metadata.gz: e77d4317b3cfdd887b3a79497498e5117a9e7ce1c38670c5b045b34eb2926c54
4
+ data.tar.gz: decabac10b6b204e9518444c7bb4cc363746e33df37749335f8da88aaa59c0a4
5
5
  SHA512:
6
- metadata.gz: 1c2bc15ede221fc4128d62be93abd9dc6eb6137dd409faf763507c938b9d4bfdb4dd79af78d7de3f195ce1758dc72d5b6d1096c9b28893062c54db90c1a179bc
7
- data.tar.gz: 32a0b2014027182f2c357b76defd7402fbc4996d994c5e8f3189844c66d634c16cfd26b9e0c524af3328bf347c5bbf608a480d85f927a021de81ce037543b760
6
+ metadata.gz: 874208f1793f8824d98bf84cb5f72c720780d4c8c7be01d872693e80a97bd469f6e06638fa9cbfe1c44b8276eac7f9d5b7731051488d78a17a5995344ed10c9d
7
+ data.tar.gz: 87e1ee1a293c2cd58a1e64f2129db7b76d6ff766832ab48901f22031fabf53823ae4c7487e033366737ed56caabbc2fddc2c197ad2153c74c9cafb95169deef8
@@ -1,7 +1,9 @@
1
1
  name: Main
2
2
  on:
3
3
  push:
4
- workflow_dispatch:
4
+ branches: [release]
5
+ pull_request:
6
+ types: [opened, synchronize]
5
7
 
6
8
  jobs:
7
9
  tests:
@@ -1,6 +1,6 @@
1
1
  module Minitest
2
2
  # :nodoc:
3
3
  module Junit
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
6
6
  end
@@ -28,11 +28,12 @@ module Minitest
28
28
  end
29
29
 
30
30
  def report
31
- doc = Ox::Document.new(:version => '1.0')
31
+ doc = Ox::Document.new(version: '1.0', encoding: 'UTF-8')
32
32
  instruct = Ox::Instruct.new(:xml)
33
33
  instruct[:version] = '1.0'
34
34
  instruct[:encoding] = 'UTF-8'
35
35
  doc << instruct
36
+
36
37
  testsuite = Ox::Element.new('testsuite')
37
38
  testsuite['name'] = @options[:name] || 'minitest'
38
39
  testsuite['timestamp'] = @options[:timestamp]
@@ -46,7 +47,10 @@ module Minitest
46
47
  testsuite << format(result)
47
48
  end
48
49
 
49
- doc << testsuite
50
+ testsuites = Ox::Element.new('testsuites')
51
+ testsuites << testsuite
52
+
53
+ doc << testsuites
50
54
  @io << Ox.dump(doc)
51
55
  end
52
56
 
@@ -58,6 +62,7 @@ module Minitest
58
62
  testcase['file'] = relative_to_cwd(result.source_location.first)
59
63
  testcase['line'] = result.source_location.last
60
64
  testcase['assertions'] = result.assertions
65
+
61
66
  if result.skipped?
62
67
  skipped = Ox::Element.new('skipped')
63
68
  skipped['message'] = result
@@ -72,6 +77,16 @@ module Minitest
72
77
  end
73
78
  end
74
79
 
80
+ # Minitest 5.19 supports metadata
81
+ # Rails 7.1 adds `failure_screenshot_path` to metadata
82
+ # Output according to Gitlab format
83
+ # https://docs.gitlab.com/ee/ci/testing/unit_test_reports.html#view-junit-screenshots-on-gitlab
84
+ if result.respond_to?("metadata") && result.metadata[:failure_screenshot_path]
85
+ screenshot = Ox::Element.new("system-out")
86
+ screenshot << "[[ATTACHMENT|#{result.metadata[:failure_screenshot_path]}]]"
87
+ testcase << screenshot
88
+ end
89
+
75
90
  testcase
76
91
  end
77
92
 
@@ -89,10 +104,6 @@ module Minitest
89
104
  @working_directory ||= Dir.getwd
90
105
  end
91
106
 
92
- def failure_message(result)
93
- "#{result.klass}##{result.name}: #{result.failure}"
94
- end
95
-
96
107
  def relative_to_cwd(path)
97
108
  path.sub(working_directory, '.')
98
109
  end
@@ -14,11 +14,23 @@ class ReporterTest < Minitest::Test
14
14
  reporter.report
15
15
 
16
16
  assert_match(
17
- %r{<?xml version="1.0" encoding="UTF-8"\?>\n<testsuite name="minitest" timestamp="[^"]+" hostname="[^"]+" tests="0" skipped="0" failures="0" errors="0" time="0.000000"\/>},
17
+ %r{<?xml version="1.0" encoding="UTF-8"\?>\n<testsuites>\n <testsuite name="minitest" timestamp="[^"]+" hostname="[^"]+" tests="0" skipped="0" failures="0" errors="0" time="0.000000"\/>\n<\/testsuites>\n},
18
18
  reporter.output
19
19
  )
20
20
  end
21
21
 
22
+ # NOTE: This test will generate a temp file: "test/tmp/report.xml"
23
+ def test_encoding
24
+ # Enforce File.external_encoding to UTF-8 to ensure that ASCII character will be correctly converted to UTF-8
25
+ file = File.new('test/tmp/report.xml', 'w:UTF-8')
26
+ reporter = Minitest::Junit::Reporter.new file, { hostname: '‹foo›' }
27
+ reporter.start
28
+ reporter.report
29
+ file.close
30
+
31
+ assert_match(/hostname="‹foo›"/, File.new('test/tmp/report.xml', 'r:UTF-8').read)
32
+ end
33
+
22
34
  def test_formats_each_successful_result_with_a_formatter
23
35
  reporter = create_reporter
24
36
 
@@ -37,8 +49,9 @@ class ReporterTest < Minitest::Test
37
49
  results.each do |result|
38
50
  parsed_report.xpath("//testcase[@name='#{result.name}']").any?
39
51
  end
40
- # Check if some testcase has a failure
52
+ # Check if some testcase has a failure and screenshot path
41
53
  assert parsed_report.xpath("//testcase//failure").any?
54
+ assert parsed_report.xpath("//testcase//system-out").any?
42
55
  end
43
56
 
44
57
  def test_xml_nodes_has_file_and_line_attributes
@@ -81,6 +94,11 @@ class ReporterTest < Minitest::Test
81
94
  end
82
95
  end.new
83
96
  end
97
+
98
+ if failures.positive?
99
+ test.metadata[:failure_screenshot_path] = '/tmp/screenshot.png'
100
+ end
101
+
84
102
  Minitest::Result.from test
85
103
  end
86
104
 
data/test/tmp/.keep ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-junit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allan Espinosa
@@ -135,6 +135,7 @@ files:
135
135
  - test/junit_plugin_test.rb
136
136
  - test/reporter_test.rb
137
137
  - test/testcase_formatter_test.rb
138
+ - test/tmp/.keep
138
139
  homepage: http://github.com/aespinosa/minitest-junit
139
140
  licenses:
140
141
  - MIT
@@ -163,3 +164,4 @@ test_files:
163
164
  - test/junit_plugin_test.rb
164
165
  - test/reporter_test.rb
165
166
  - test/testcase_formatter_test.rb
167
+ - test/tmp/.keep