Dmitry V. Sabanin [mailto:sdmitry / lrn.ru] wrote:

> I want to do something similiar to, but for a test case:
>   def self.suite
>     suite = Test::Unit::TestSuite.new "Muravey News System Tests"
>   end
>   where output is:
>   Loaded suite Muravey News System Tests
>   Started
>   FFF
>   Finished in 0.008444 seconds.
> 
>   Now output for testcases is:
>   1) Failure!!!
>   test_get_news(TC_MNS_View_News) [./tests/test_view.rb:28]:
>   
> I want TC_MNS_Views_News to be replaced with my own string, like in 
> TestSuite. If it's not possible i will live with that :)

This (or some variant) will work:

  require 'test/unit'

  class Test::Unit::TestCase
    def name
      "#@method_name(#{self.class.fixture_name})"
    end
  end

  class TC_Me < Test::Unit::TestCase
    def self.fixture_name
      "It's all about ME!"
    end

    def test_me
      flunk
    end
  end

Output:

  Loaded suite t
  Started
  F
  Finished in 0.02 seconds.

    1) Failure!!!
  test_me(It's all about ME!) [t.rb:15]:

  1 tests, 1 assertions, 1 failures, 0 errors

I'm not sure I like this... the point of having the class name there is that
it makes it easier to figure out where in the world the failure occurred.
It's your code, though :-)

HTH,


Nathaniel

<:((><