| 1 |
require_relative "../../test_helper" |
| 2 |
|
| 3 |
module MinitestReportersTest |
| 4 |
class JUnitReporterTest < TestCase |
| 5 |
def test_replaces_special_characters_for_filenames_and_doesnt_crash |
| 6 |
fixtures_directory = File.expand_path('../../../fixtures', __FILE__) |
| 7 |
test_filename = File.join(fixtures_directory, 'junit_filename_bug_example_test.rb') |
| 8 |
output = `ruby #{test_filename} 2>&1` |
| 9 |
refute_match 'No such file or directory', output |
| 10 |
end |
| 11 |
|
| 12 |
if Gem::Version.new(Minitest::VERSION) >= Gem::Version.new('5.19.0') |
| 13 |
def test_outputs_screenshot_metadata |
| 14 |
test = Minitest::Test.new('test_fail') |
| 15 |
test.define_singleton_method(:test_fail) { assert false } |
| 16 |
test.metadata = { failure_screenshot_path: 'screenshot.png' } |
| 17 |
|
| 18 |
reporter = Minitest::Reporters::JUnitReporter.new('test/tmp') |
| 19 |
reporter.start |
| 20 |
reporter.record(test.run) |
| 21 |
reporter.report |
| 22 |
|
| 23 |
test_output = File.read('test/tmp/TEST-Minitest-Test.xml') |
| 24 |
assert_includes test_output, '<system-out>[[ATTACHMENT|screenshot.png]]</system-out>' |
| 25 |
end |
| 26 |
end |
| 27 |
end |
| 28 |
end |