Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8740397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:07:27+00:00 2026-06-13T11:07:27+00:00

When I look into the implementation of FRIEND_TEST at https://github.com/google/googletest/blob/master/googletest/include/gtest/gtest_prod.h , I see the

  • 0

When I look into the implementation of FRIEND_TEST at https://github.com/google/googletest/blob/master/googletest/include/gtest/gtest_prod.h, I see the following:

#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
// When you need to test the private or protected members of a class,
// use the FRIEND_TEST macro to declare your tests as friends of the
// class.  For example:
//
// class MyClass {
//  private:
//   void MyMethod();
//   FRIEND_TEST(MyClassTest, MyMethod);
// };
//
// class MyClassTest : public testing::Test {
//   // ...
// };
//
// TEST_F(MyClassTest, MyMethod) {
//   // Can call MyClass::MyMethod() here.
// }
#define FRIEND_TEST(test_case_name, test_name)\
friend class test_case_name##_##test_name##_Test
#endif 

If my understanding is correct, the test class is made a child of the production class unconditionally. This would make the production class dependent on the test class. In effect, the production code will contain my test libraries too.

I am not sure if this is the right thing to do.

Am I missing something here or should this be compiled conditionally only?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:07:28+00:00Added an answer on June 13, 2026 at 11:07 am

    I don’t read it like that. You can make a made up non-existing class a friend of your production class if you want. It’s harmless, and it certainly doesn’t introduce a dependency or add testing code to your production code.

    class Production
    {
       friend class WibbleWibble;
       ...
    };
    

    This code is perfectly correct even if WibbleWibble doesn’t exist. So there is no dependency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help me look into my simple test case: import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import
I have started to look into python and am trying to grasp new things
I want to look into developing mobile applications using HTML5. I'm very new to
I've yet to look into storing files such as Word, Excel, etc. into MongoDB
As I look into documentation of GKScore and GKLeaderboard, there is no way to
I have to look into solutions for providing a MySQL database that can handle
Im trying to look into using the WPF WriteableBitmap class to allow my application
I've been asked to look into an issue where flash ads are not displaying
So far I know that FileSystemWatcher can look into a folder and if any
I have been asked to look into FileMaker for creating a pretty simple database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.