# Unable to change output of test suite

**URL:** <https://www.ruby-forum.com/t/unable-to-change-output-of-test-suite/113510>\
**Category:** Ruby\
**Created:** [August 31, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/unable-to-change-output-of-test-suite/113510 "2007-08-31T23:42:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yossef\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/a87d85/32.png) [@Yossef\_M](https://www.ruby-forum.com/u/Yossef_M)\
**Post date:** [August 31, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/unable-to-change-output-of-test-suite/113510/1 "2007-08-31T23:42:42Z")

</div>

I’m trying to change the output of a test suite, and from what I can  
tell the one line I’m interested in (the indication of numbers of  
tests, assertions, failures, and errors) is generated by  
Test::Unit::TestResult#to\_s. It seems like a simple change, but I’m  
running into trouble.

The following code:

require ‘test/unit’

class Test::Unit::TestResult  
def to\_s() ‘this should be different’; end  
end

class WeirdnessTest \< Test::Unit::TestCase  
end

Gives me this result:

Loaded suite test\_weirdness  
Started  
F  
Finished in 0.000871 seconds.

1. Failure:  
default\_test(WeirdnessTest) [test\_weirdness.rb:7]:  
No tests were specified.

1 tests, 1 assertions, 1 failures, 0 errors

Is there some dark magic with test suites or am I just missing  
something simple? After looking through some of the test/unit code,  
I’m not even sure where Test::Unit::TestResult objects come from, but  
I’m still somewhat convinced they’re necessary

---

<div class="post-metadata">

**Author:** ![Yossef\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/a87d85/32.png) [@Yossef\_M](https://www.ruby-forum.com/u/Yossef_M)\
**Post date:** [September 1, 2007, 3:06am UTC](https://www.ruby-forum.com/t/unable-to-change-output-of-test-suite/113510/2 "2007-09-01T03:06:56Z")

</div>

Hi,

At Sat, 1 Sep 2007 06:34:14 +0900,  
Yossef M. wrote in [ruby-talk:266993]:

> require ‘test/unit’  
> require ‘test/unit/testresult’
> 
> class Test::Unit::TestResult  
> def to\_s() ‘this should be different’; end  
> end
> 
> class WeirdnessTest \< Test::Unit::TestCase  
> end

test/unit.rb just defines Test::Unit, but not TestResult, and  
test/unit/testresult.rb isn’t loaded until any TestRunner  
libraris get loaded. So your TestResult is overridden by the  
true TestResult definition.

---

<div class="post-metadata">

**Author:** ![Yossef\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/a87d85/32.png) [@Yossef\_M](https://www.ruby-forum.com/u/Yossef_M)\
**Post date:** [September 1, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/unable-to-change-output-of-test-suite/113510/3 "2007-09-01T17:42:24Z")

</div>

On Aug 31, 8:06 pm, Nobuyoshi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > def to\_s() ‘this should be different’; end  
> > –  
> > Nobu Nakada

Of course it had to be something simple like that.

Thank you very much.
