mercredi 18 novembre 2015

logger in ruby unit test startup or setup

I am writing some tests in ruby and have this question.

class MyTest < Test::Unit::TestCase
    LogFile = "test.log"
    Log= Logger.new(LogFile)

    def startup
       @log = Log
    end

    def shutdown
    end

    def setup
    end

   ....

end

I am trying to create a logger in startup, however, it does not work well. In the test cases, @log is nil. I know I can put it in setup, however, I don't want to reassign it for every test case. Why it does not work? What is the correct way to do it?

Aucun commentaire:

Enregistrer un commentaire