[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Retrieving the testcase name in class inheriting unit testca

Anil Gollaa

4/26/2009 6:24:00 PM

Hi,
How can i retrieve the testcase name, while running the testcases of the
class
inherited by unit testcase.

For example in the below script
I would like to access the testcase name in setup function.

Testscript
require "test/unit"

class TestSimpleNumber < Test::Unit::TestCase

def setup
# need to get the testcase name that is executed when we run the the
testcases
# using ruby
end

def test_simple
assert_equal("abc", "abc" )

end
End

Please help me in this regard.
--
Posted via http://www.ruby-....

2 Answers

Robert Klemme

4/26/2009 7:22:00 PM

0

On 26.04.2009 20:23, Anil Gollaa wrote:
> Hi,
> How can i retrieve the testcase name, while running the testcases of the
> class
> inherited by unit testcase.
>
> For example in the below script
> I would like to access the testcase name in setup function.
>
> Testscript
> require "test/unit"
>
> class TestSimpleNumber < Test::Unit::TestCase
>
> def setup
> # need to get the testcase name that is executed when we run the the
> testcases
> # using ruby

Do you mean like

@name = self.class.name

? This seems superfluous as you can invoke that chain from any of the
tests.

> end
>
> def test_simple
> assert_equal("abc", "abc" )
>
> end
> End

Cheers

robert

Powerglide

4/27/2009 4:17:00 PM

0

def test_simple
puts "Executing the testcase : #{self.method_name}"
assert_equal("abc","abc")

#or
puts "End of testcase : #{self.method_name}"
end



On Apr 26, 12:22 pm, Robert Klemme <shortcut...@googlemail.com> wrote:
> On 26.04.2009 20:23, Anil Gollaa wrote:
>
>
>
>
>
> > Hi,
> > How can i retrieve the testcase name, while running the testcases of the
> > class
> > inherited by unit testcase.
>
> > For example in the below script
> > I would like to access the testcase name in setup function.
>
> > Testscript
> > require "test/unit"
>
> > class TestSimpleNumber < Test::Unit::TestCase
>
> >   def setup
> >   # need to get the testcase name that is executed when we run the the
> > testcases
> >   # using ruby
>
> Do you mean like
>
> @name = self.class.name
>
> ?  This seems superfluous as you can invoke that chain from any of the
> tests.
>
> >   end
>
> >   def test_simple
> >     assert_equal("abc", "abc" )
>
> >   end
> > End
>
> Cheers
>
>         robert- Hide quoted text -
>
> - Show quoted text -