Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-82823

Consider support for parameterized unit tests (TEST_P)

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • Labels:
      None
    • Service Arch

      It is often useful to run a suite of tests multiple times, varying one or more parameters.

      GTest supports this through value-parameterized tests.

      For example:

       class FixtureClass : TestWithParam<int> {
       };
       
      TEST_P(FixtureClass, TestThatUsesParameterizedFixture) {
          int param = GetParam();
          // ... do a test using the given parameter
      }
      
      TEST_P(FixtureClass, AnotherTestThatUsesParameterizedFixture) {...}
      
      INSTANTIATE_TEST_SUITE_P(SomeUniquePrefix, FixtureClass, Values(1, 2, 3, 4))
      

      Such functionality would be a useful addition to the unittest framework, as it does not appear to currently be supported.

      To explore the viability of adding this to the framework, I've created a proof of concept: github.

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            james.harrison@mongodb.com James Harrison
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: