Object-Oriented Flavor for JUnit Tests

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thanks. I think like an audience want to test exactly what is going on inside of an object. Want to test the procedural method calls inside of object don't understanding that object will always encapsulate that so it can change internal thing safely. We don't need to test that object has called particular method - that's the wrong test. Object is a black box and we can only test the results of behavior of the object (the side effect) but not exactly what method was called to reach that result. It is just procedural mindset of an audience. Anyway, it is really interesting and when you try not to do procedures even inside the tests it can definitely affect the design of an object that is tested as it was shown on report. So I will add this as another benefit and it's really huge one. Thanks again on getting me to rethink my code and get better usage of objects and paradigm itself.

tolegenizbassar
Автор

When you scramble the letters of a word to make one or more new words, you call the result an anagram. Hamcrest is an anagram of Matchers. You pronounce this word the way it looks, so you don't have to worry in this case that the spelling is strange.

michaeljuliano
Автор

There is a problem with matchers creation: yes, matcher creation isn't so easily than static method creation. So, ppl ask me why the hell we need implement some complex solution then I can reach the same results with smth simpler? Then I tell them matchers are reusable ppl answer: YAGNI. So why we have to implement smth we use only 1 time?

Thus, theoretically, matchers creation is a good idea but, practically, I start with static methods AND THEN if I use them 2-3 times I create a matcher.

Kon-Tiky