title: How to run Parameterized Tests with fixture member values in Google Test (gtest)?
body: <p>What I want to achieve is a Paramaterized Test <code>TEST_P(MyFixtureClass, DoStuff)</code>, with which I can test different values. Though said values shouldn't be constants, like those typically passed to <code>INSTANTIATE_TEST_CASE_P</code>. Moreover, I would want to use the values within some other fixture class - ideally.</p>
  
  <p>There doesn't seem to be anything out there, which covers using fields instead of static values when creating parameterized tests. The <a href="https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#how-to-write-value-parameterized-tests" rel="noreferrer">official documentation</a> doesn't seem to cover this either - sadly.</p>
  
  <hr/>
  
  <p>But to avoid introducing the XY-problem in this question, here is the equivalent pseudo code:</p>
  
  <p>The parameterized fixture, <code>MyFixture</code>:</p>
  
  <pre><code>struct MyFixture : OtherFixture, ::testing::WithParamInterface&lt;float&gt;
  {
      float a;
  
      void SetUp() override
      {
          a = GetParam();
      }
  };
  </code></pre>
  
  <p><code>OtherFixture</code> would look like this:</p>
  
  <pre><code>struct OtherFixture : testing::Test
  {
      float a;
      float b;
      float c;
  
      void SetUp() override
      {
          a = CalculateSomeFloat();
          b = CalculateSomeFloat();
          c = CalculateSomeFloat();
      }
  };
  </code></pre>
  
  <p>The test case would be something like:</p>
  
  <pre><code>// This here is the key aspect.
  // Basically, I do not want to write a bunch of tests for a, b and c.
  // Rather, I'd just test all 3 with this one.
  TEST_P(MyFixture, DoStuff)
  {
      ...bunch of tests
  }
  </code></pre>
  
  <p>And lastly, we would instantiate the parameterized tests:</p>
  
  <pre><code>INSTANTIATE_TEST_CASE_P(MyFloatTesting, MyFixture, ::testing::Values(
      OtherFixture::a, OtherFixture::b, OtherFixture::c
  ));
  </code></pre>
  
  <p>Obviously, <code>OtherFixture::a</code> is inappropriate, but it illustrates where I would want to refer to a field, within a inherited fixture class (or any fixture class for that matter).</p>
  
  <hr/>
  
  <p>So is there any way to achieve this with gtest? I do not necessarily need to use parameterized tests. Simply avoiding having to write the same tests, for different objects is fine by me.</p>
  
  <p><br/>Any suggestions are much appreciated!</p>