How do I unit test the methods in a method object?

非 Y 不嫁゛ 提交于 2019-12-03 07:46:01

I'll answer my own question. After a bit of reading and thinking, I believe I shouldn't be unit testing these private methods. I should just test the public interface. If the private methods that do the internal processing are important enough to test independently and are not just coincidences of the current implementation, then perhaps this is a sign that they should be refactored out into a separate class.

I like your answer, but i disagree.

The situation where you would use this design pattern is one where there is a fairly complex operation going on. As a result being abel to verify the individual components of such an operation i would say is highly desirable.

You then have the issue of dependancies on other resources (which may or may not be true in this case).

You need to be able to use some form of ioc in order to inject some form of mock to isolate the class.

Besides most mocking frameworks will provide you with accessors to get at the private members.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!