lib/minitest/junit.rb in minitest-junit-2.0.1 vs lib/minitest/junit.rb in minitest-junit-2.1.0
- old
+ new
@@ -60,10 +60,11 @@
testcase['name'] = format_name(result)
testcase['time'] = format_time(result.time)
testcase['file'] = relative_to_cwd(result.source_location.first)
testcase['line'] = result.source_location.last
testcase['assertions'] = result.assertions
+
if result.skipped?
skipped = Ox::Element.new('skipped')
skipped['message'] = result
skipped << ""
testcase << skipped
@@ -72,9 +73,19 @@
failure_tag = Ox::Element.new(classify(failure))
failure_tag['message'] = result
failure_tag << format_backtrace(failure)
testcase << failure_tag
end
+ end
+
+ # Minitest 5.19 supports metadata
+ # Rails 7.1 adds `failure_screenshot_path` to metadata
+ # Output according to Gitlab format
+ # https://docs.gitlab.com/ee/ci/testing/unit_test_reports.html#view-junit-screenshots-on-gitlab
+ if result.respond_to?("metadata") && result.metadata[:failure_screenshot_path]
+ screenshot = Ox::Element.new("system-out")
+ screenshot << "[[ATTACHMENT|#{result.metadata[:failure_screenshot_path]}]]"
+ testcase << screenshot
end
testcase
end