unit test

1) State vs Behaviour Verification
https://manas.tech/blog/2009/04/30/state-vs-behaviour-verification.html

2) Unit testing a class with no return value?
http://stackoverflow.com/questions/1607339/unit-testing-a-class-with-no-return-value
we should test it only when it's functionality is vital, then we can use mock objects in the test, see 1)

3) Should I test private methods or only public ones?
http://stackoverflow.com/questions/105007/should-i-test-private-methods-or-only-public-ones
a complete test for public function is enough.
private/protected methods are not parts of the API, they are basically implementation choices (we can change to some other implementation),
that you can decide to review, update or throw away completely without any impact on the outside.
and testing private methods separately won't make the overall test complete no matter how hard you try.
(Private functions mainly exists in our class because we want to create readable code in our public methods)

posted @ 2017-04-17 15:19  HEIS老妖  阅读(132)  评论(0编辑  收藏  举报