3 ms·
The assumption is that your public members are your interface. Anything private is an internal implementation detail, possibly subject to future change or repla
by khedoros1 10y ago
The assumption is that your public members are your interface. Anything private is an internal implementation detail, possibly subject to future change or replacement.
Thorough testing of the public methods should end up calling all of the private methods. Of course, that's a best case scenario. In C++ at least, it'd be an option to make a testing class that's a friend of the class it tests. Then you could test the private members individually.
- justicezyx 10y agoI think almost all modern languages end up with granting (unit) testing code free access to everything. The idea of testing only the public interface is about an unique snow flake only meaningful in C++ design, and was never a viable practice at all. Otherwise, I'd say at least one other language follow the similar approach...
- khedoros1 10y agoAre you just complaining about a lack of introspection to get around access controls? Friend classes are better for encapsulation than introspection is.