Dear Bo,
Thank you for this post! I found it quite interesting because it revealed to me a totally different point of view about unit testing! I have never asked myself what is a unit as I’ve always felt that, quite naturally, the unit is the class :-). I turns out that may not be that natural to everybody. I think anyway that there can be situations where a single class function can be considered a unit and it can be tested separately, possibly as part of a white-box test. In my opinion it is definitely good to know the two points of view and choose the better one depending on the context!
Thanks for sharing your experience with us! Maybe someone else would have interesting comments as well.
Best regards,
Peter
Bob wrote:Hallo everyone,
After reading some code, I started to do some unit test now, so that I can become familiar with the code.
Because I have worked in C for a long time, and I often “think in C”, when I started with the class NodeCache, I tried to test the internal functions. I considered the methods of a class as a “unit”. It led to the details of the implementation of the class and I did not concentrate in the usage of the class.
But in C++ the unit should be a class, and the behavior of the class should be tested. We need to look at the class from outside and try to use it in all possible cases. The internal methods should be kept hidden.This is my first experience of doing unit test in Calitko. I would like to share it with you. If you have any comments or suggestions, I am very glad to hear that.
I plan to do the unit test for classes in Gnutella first.
Best regards,Bo
