2009/11/23 Joel Fielder <joel.fiel...@switchplane.com>: > Hi, > > Personally, I'd prefer not. I want the compiler to tell me if I invoke > a private method. Also, I have to be sure that the tests are testing > exactly the same thing as my apps are using, particularly with respect > to templates.
But the compiler will tell you anyway when you build your program normally? I don't think there's any point in relying on UT++ to do type-checking/code-not-calling-private-methods-checking and other things that are dealt with by the compiler automatically. Unit testing is for catching what would become logical runtime errors, not errors that will be caught at compile time. > If you need to test it, you can either extract the method or make it > public static, or make a class called Midpoint and put the method in > that, public static. The latter would be my preference (unless you can > use std::binary_search). Why go to all that trouble mutilating the code under test to get around a limitation in UT++ when a couple of lines in UT++ will do the same job (and in the right place)? I've heard the advice that private methods indicate that a new class should be created where that functionality is public, but it would surely be overkill to do that in every case. > I guess if you can make it optional then it can be used, but I think it > goes against UnitTest++ principles! I suppose this is where most people are really objecting. But I think the opposite is true: unit testing is not a normal usage of a class. It goes beyond the normal class access specifier system, which is meant to help encapsulation for normal usage of the class. To refuse to test private members because they're private is too rigid and inflexible IMO, and frankly not a sensible decision. You should test all of your code at the level of granularity that /feels right/, not simply the degree that public/private rules tell you. Oisín ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ unittest-cpp-devel mailing list unittest-cpp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel