2009/3/6 William Chan (陈智昌) <[email protected]>: > 2009/3/6 Scott Hess <[email protected]>: >> I just wanted to make sure I understood your proposal. >> >> Right now, test classes want to be in the anonymous namespace so that >> unit test files do not have to coordinate with each other in the >> naming of test classes. With your proposal, the thing which is >> exposed outside of the anonymous namespace (MyClassPeer) is based on a >> thing already known to be unique (MyClass), so coordinate is not an >> issue unless you have multiple unit test files testing the same class. >> There are still just as many items exposed outside of the anonymous >> namespace, but they are named in a way which prevents collisions. >> >> Is that about right? > > Mostly right. It's fewer things exposed outside of the anonymous > namespace, since previously you needed each TEST/TEST_F class to exist > outside the anonymous namespace in order for you to FRIEND_TEST it. > In this way, you only have one Peer per class you're testing. I don't > know enough about Chrome yet, but if there were some very commonly > used classes, then it might make sense to put the Peer class in a > header file for multiple tests to share. My gut instinct is this use > case doesn't happen enough in Chrome to make it worthwhile, but I have > no clue. It made more sense in the Google code base for various > reasons. > > Also, I'm a big fan of testing via the public interface methods as > much as possible. Hopefully we don't need to friend most classes in > order to tell them well.
The complaint I got about putting the test class outside the anonymous namespace is that there was another completely unrelated test far away which used the same name (and was also outside the anonymous namespace, but could be put inside). Having files implementing unittests around a single class needing to coordinate with each other seems much more reasonable. Thanks, scott --~--~---------~--~----~------------~-------~--~----~ Chromium Developers mailing list: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---
