I'm thinking C++, I imagine JS may have different answers or suggestions. Do we have a precedent or a preferred approach when unit testing requires changes or additions to the code?
For example, a public method (which we want to test in the unit test) has a number of side effects, but we don't have the public accessors to examine all of those private side effects/state. There is a number of things that could be done to accomplish this. Off the top of my head, without advocating any of these and in no particular order: Add public accessors, even if they're (currently) only used by the unit tests. Make the private members protected, derive a class inside the unit test code and put the public accessors there. Make the unit test class a friend of the original class so that it can access private members. Extend the signature of the method in question to allow the "return" of all the side effects. Take the fact that you can't see side effects as a sign of bad design, because that means the non-unit test code cannot check if the right thing happened. (I imagine that would lead to #1 or #4 or some combination of those.) Thoughts or precedents? Milan _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform