What is the Humble Object pattern and when is it useful?

前端 未结 3 1228
清歌不尽
清歌不尽 2020-12-15 04:22

I was reading an article by Dino Esposito on how to test AsyncConrollers in ASP.NET MVC and in there he uses the \"Humble Object\" pattern, without going into much detail.

3条回答
  •  时光说笑
    2020-12-15 05:22

    There is a thorough description at xunitpatterns.com.

    Basically, you pull all the logic into a separate object which you can easily test - and your "Humble Object" becomes a wrapper around your testable object; it's just that the humble object also has dependencies on things that are difficult to test, like async services or GUI classes. The idea being to leave so little actual logic in the humble object that you don't need to test it, and so don't need to deal with testing the difficult to test dependency.

提交回复
热议问题