I am generating some output files during the execution of rails tests, and I would like to be able to name the files based o开发者_C百科n the current test class and current test method. Is there a way to get this information built into Test::Unit? Is there some clever way to get this from inside the test methods? I can get the current method name by calling method, but I can't figure out how to get the current class name.
Calling self.class returns Controller, not the actual test class ( PostTest, for example ).
This should return your class name in unit test:
test "class name" do
puts "#{self.class.name}"
end
Are you saying this is not working for you? It should work.
精彩评论