Ask a Question related to Ruby, Design and Development.
-
Dmitry V. Sabanin #1
TestCase human-readable name
Hello!
I have a question about TestUnit. How can i set a human-readable name for my
TestCase? I see name argument for a new, but i don't know where class
instance is initialized. That would be nice if i could change name of TC from
setup().
--
sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Dmitry V. Sabanin Guest
-
#39804 [NEW]: Testcase 008.phpt is getting failed.
From: shaamcom_83 at yahoo dot co dot in Operating system: Linux PHP version: 5.2.0 PHP Bug Type: CGI related Bug... -
Type on human face
OS 9.2.2 PS 7 Will someone please point me in the direction of a tutorial that will inform me as to how I might superimpose type on a human face... -
debug testcase keyword
I am working on a regexp engine, where I follow the test first paradigm. I want my regexp-engine to be compatible with Ruby's, therefore I share... -
Is there a way to print out the contents of a variable in human readable format?
Is it possible to print out the contents of a variable in a human readable format? For instance like PHP's print_r() function? Thanks in... -
Idea for a better use of human intelligence
Hello, About the tecnical aspect of my "Idea for a better use of human intelligence" I was told, that it could be realized in php.... -
Nathaniel Talbott #2
Re: TestCase human-readable name
Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:
my> I have a question about TestUnit. How can i set a human-readable name forfrom> TestCase? I see name argument for a new, but i don't know where class
> instance is initialized. That would be nice if i could change name of TCI'm having trouble understanding what it is you want to change the name of.> setup().
In Test::Unit, what happens is that your TestCase class is initialized once
for each test that it contains. So if you have a TestCase like this:
class TC_Me < Test::Unit::TestCase
def test_me
end
def test_me_too
end
end
The framework will call the constructor of your TestCase once for each test:
TC_Me.new(:test_me)
TC_Me.new(:test_me_too)
Thus, the TestCase is 'named' once for each test that it contains.
I'm guessing that you're asking this question because you want to change the
output somehow... I might be able to help more if I can get a better feel
for what you're trying to accomplish.
HTH,
Nathaniel
<:((><
Nathaniel Talbott Guest
-
Dmitry V. Sabanin #3
Re: TestCase human-readable name
On Friday 08 August 2003 22:21, Nathaniel Talbott wrote:
I want to do something similiar to, but for a test case:> Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:>> > I have a question about TestUnit. How can i set a human-readable name for
> my
>>> > TestCase? I see name argument for a new, but i don't know where class
> > instance is initialized. That would be nice if i could change name of TC
> from
>>> > setup().
> I'm having trouble understanding what it is you want to change the name of.
> In Test::Unit, what happens is that your TestCase class is initialized once
> for each test that it contains. So if you have a TestCase like this:
>
> class TC_Me < Test::Unit::TestCase
> def test_me
> end
>
> def test_me_too
> end
> end
>
> The framework will call the constructor of your TestCase once for each
> test:
>
> TC_Me.new(:test_me)
> TC_Me.new(:test_me_too)
>
> Thus, the TestCase is 'named' once for each test that it contains.
>
> I'm guessing that you're asking this question because you want to change
> the output somehow... I might be able to help more if I can get a better
> feel for what you're trying to accomplish.
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 :)--> HTH,
>
>
> Nathaniel
>
> <:((><
sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Dmitry V. Sabanin Guest
-
Nathaniel Talbott #4
Re: TestCase human-readable name
Dmitry V. Sabanin [mailto:sdmitry@lrn.ru] wrote:
This (or some variant) will work:> 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 :)
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
<:((><
Nathaniel Talbott Guest
-
Dmitry V. Sabanin #5
Re: TestCase human-readable name
On Saturday 09 August 2003 00:06, Nathaniel Talbott wrote:
Thanks a lot Nataniel!> 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 :-)
Class name is good for searching where the failure is, but line number is more
usefull for me (class name don't give me much information, as for example
name of section where error happened do). But there is not much difference
here..
--> HTH,
>
>
> Nathaniel
>
> <:((><
sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Dmitry V. Sabanin Guest



Reply With Quote

