--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALjhuifVPTPNYaKK20o4runexdpwnzFWjix9T%2B-s2yOHL_ETzw%40mail.gmail.com.
I think using adding a helper class that's a friend of the tested class is a lot cleaner than using FRIEND_TEST / FRIEND_TEST_ALL_PREFIXES, since the list of friend tests can get quite long (and it introduces this weird coupling of production code on test code). I think consistency won't be too bad: certainly, an individual test file should be internally consistent, but using this in new test files seems like a good idea to me.I wonder why their recommendation steers clear of just having the class friend the test fixture: I guess the idea is the helper class could be shared between multiple unittest modules that way?
I think using adding a helper class that's a friend of the tested class is a lot cleaner than using FRIEND_TEST / FRIEND_TEST_ALL_PREFIXES, since the list of friend tests can get quite long (and it introduces this weird coupling of production code on test code). I think consistency won't be too bad: certainly, an individual test file should be internally consistent, but using this in new test files seems like a good idea to me.I wonder why their recommendation steers clear of just having the class friend the test fixture: I guess the idea is the helper class could be shared between multiple unittest modules that way?
I agree that not accessing the private details is better, when possible. But in the case that's not possible, using a friend class seems strictly better than FRIEND_TEST / FRIEND_TEST_ALL_PREFIXES.
I think everyone agrees that testing private implementation details should be avoided.
On Tue, Jul 31, 2018 at 11:36 AM Martin Kreichgauer <mart...@google.com> wrote:I think everyone agrees that testing private implementation details should be avoided.Given the current state of Chromium code, I don't believe it's true that everyone agrees on this -- or we wouldn't be doing it so pervasively and consistently, including in new changes I review.
I think it is vastly more beneficial to our testability to actually get everyone to agree on this than to fix the issue of peer classes versus FRIEND_TEST. The latter is a nice-to-have, the former is more must-have; and it's something that is not called out in our style guides or Dos-and-Don'ts page, or recommended to new team members anywhere.PK
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFBJSz-BDJ8QkFo-nB4VpKZfuMPMJxdftY2Gv_1V%3DjrXrQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALjhuicXa0FTN2MNYTRZFbg5VcF2TE5i%2BHH%2Bkosg3u%2BtYH_2GA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAKgcGXiV-SURitTmKfrvQiUKwfNecOXtMAga-jW3ZaYP6ytTnw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALcbsXAMQDrt1Mgnx3fp52VWWVOSZMNXg_%3DCP3EKiEd5AApTpQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAP_mGKrsOq2exZfY2uR4gsX2KtUb%3DT6%2Bs3hm9n8Y7q-7Ey%3D6%2Bg%40mail.gmail.com.