Retrieving the testcase name in class inheriting unit testca

A

Anil Gollaa

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.
 
R

Robert Klemme

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
 
P

Powerglide

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top