Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report failed test name in dot format output #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/turn/reporters/dot_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ def finish_suite(suite)
suite.each do |testcase|
testcase.each do |testunit|
if testunit.fail? || testunit.error?
list << testunit
list << [testcase, testunit]
end
end
end

unless list.empty? # or verbose?
#report << "\n\n-- Failures and Errors --\n\n"
list.uniq.each do |testunit|
list.uniq.each do |(testcase, testunit)|
heading = []
message = []
message << (testunit.fail? ? FAIL : ERROR)
heading << (testunit.fail? ? FAIL : ERROR)
heading << "#{testcase.name}::#{testunit.name}"
message << heading.join(' ')
message << testunit.message.tabto(2)
message << clean_backtrace(testunit.backtrace).join("\n").tabto(2)
report << "\n" << message.join("\n") << "\n"
Expand Down
20 changes: 20 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ def test_error
HERE
end

#
def setup_testunit_dotted
text = <<-HERE
class DottedTest < Test::Unit::TestCase
def test_pass
assert_equal(1,1)
end

def test_fail
assert_equal(1,2)
end

def test_error
raise
end
end
HERE
save_test(text, 'dotted_test.rb')
end

#
def setup_testunit_outline
text = <<-HERE
Expand Down
8 changes: 8 additions & 0 deletions test/test_reporters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def test_dotted
assert result.index('0 errors'), "ACTUAL RESULT:\n#{result}"
end

def test_dotted_shows_name
file = setup_testunit_dotted
result = turn '--dotted', file
assert result.index('FAIL DottedTest::test_fail'), "ACTUAL RESULT:\n#{result}"
assert result.index('ERROR DottedTest::test_error'), "ACTUAL RESULT:\n#{result}"
assert !result.index('test_pass'), "ACTUAL RESULT:\n#{result}"
end

def test_marshal
file = setup_testunit
result = turn '--marshal', file
Expand Down