开发者

Introspection during Rails Test Execution -- How?

开发者 https://www.devze.com 2023-01-29 02:28 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消