Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Test::Unit's current test method name

In Ruby's Test::Unit, how do I get the current test_ method's name? In MiniTest, this can be done by self.__name__, however, it doesn't work for the full version.

like image 423
Sai Avatar asked May 27 '26 12:05

Sai


1 Answers

I got it!

The test name gets passed up the inheritance chain, so I just needed to capture it and save it locally for my reference.

def initialize(name = nil)
    @test_name = name
    super(name) unless name.nil?
end
like image 193
Sai Avatar answered May 30 '26 02:05

Sai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!