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 +4 -4
- data/.github/workflows/main.yml +3 -1
- data/lib/minitest/junit/version.rb +1 -1
- data/lib/minitest/junit.rb +17 -6
- data/test/reporter_test.rb +20 -2
- data/test/tmp/.keep +0 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77d4317b3cfdd887b3a79497498e5117a9e7ce1c38670c5b045b34eb2926c54
|
4
|
+
data.tar.gz: decabac10b6b204e9518444c7bb4cc363746e33df37749335f8da88aaa59c0a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874208f1793f8824d98bf84cb5f72c720780d4c8c7be01d872693e80a97bd469f6e06638fa9cbfe1c44b8276eac7f9d5b7731051488d78a17a5995344ed10c9d
|
7
|
+
data.tar.gz: 87e1ee1a293c2cd58a1e64f2129db7b76d6ff766832ab48901f22031fabf53823ae4c7487e033366737ed56caabbc2fddc2c197ad2153c74c9cafb95169deef8
|
data/.github/workflows/main.yml
CHANGED
data/lib/minitest/junit.rb
CHANGED
@@ -28,11 +28,12 @@ module Minitest
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def report
|
31
|
-
doc = Ox::Document.new(:
|
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
|
-
|
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
|
data/test/reporter_test.rb
CHANGED
@@ -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.
|
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
|