Unit Testing: Logging and Dependency Injection

后端 未结 9 560
臣服心动
臣服心动 2021-02-02 14:57

So regards logging from SO and other sites on the Internet the best response seems to be:

void DoSomething() {
    Logger.Log(\"Doing something!\");
    // Code.         


        
9条回答
  •  生来不讨喜
    2021-02-02 15:59

    I'd say it's probably a reasonable thing to write a Unit Test for logging; I've done so before, and it turned out to be more useful than I initially anticipated. Generally, Unit Testing logging gives you good assurance that the logging facility is working at Unit Test time, which can be a nice assurance. I don't find it critical to Unit Test logging, but if you have the inclination, I doubt that it'll be a bad thing, either.

提交回复
热议问题