# Unable to change output of test suite

**URL:** <https://rubytalk.org/t/unable-to-change-output-of-test-suite/40301>\
**Category:** ruby-talk\
**Created:** [31 August 2007 21:34 UTC](https://rubytalk.org/t/unable-to-change-output-of-test-suite/40301 "2007-08-31T21:34:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yossef\_Mendelssohn](https://avatars.discourse-cdn.com/v4/letter/y/f19dbf/32.png) [@Yossef\_Mendelssohn](https://rubytalk.org/u/Yossef_Mendelssohn)\
**Post date:** [31 August 2007 21:34 UTC](https://rubytalk.org/t/unable-to-change-output-of-test-suite/40301/1 "2007-08-31T21:34:14Z")

</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  
&nbsp;&nbsp;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.

&nbsp;&nbsp;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

> **···**
>
> --  
> -yossef

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [1 September 2007 01:06 UTC](https://rubytalk.org/t/unable-to-change-output-of-test-suite/40301/2 "2007-09-01T01:06:23Z")

</div>

Hi,

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

> require 'test/unit'

&nbsp;&nbsp;require 'test/unit/testresult'

> class Test::Unit::TestResult  
> &nbsp;&nbsp;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.

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Yossef\_Mendelssohn](https://avatars.discourse-cdn.com/v4/letter/y/f19dbf/32.png) [@Yossef\_Mendelssohn](https://rubytalk.org/u/Yossef_Mendelssohn)\
**Post date:** [1 September 2007 15:33 UTC](https://rubytalk.org/t/unable-to-change-output-of-test-suite/40301/3 "2007-09-01T15:33:14Z")

</div>

Of course it had to be something simple like that.

Thank you very much.

> **···**
>
> On Aug 31, 8:06 pm, Nobuyoshi Nakada \<n...@ruby-lang.org\> wrote:
> 
> > Hi,
> > 
> > At Sat, 1 Sep 2007 06:34:14 +0900,  
> > Yossef Mendelssohn wrote in [ruby-talk:266993]:\> require 'test/unit'
> > 
> > &nbsp;&nbsp;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.
> > 
> > --  
> > Nobu Nakada
> 
> --  
> -yossef
