[SERVER-82823] Consider support for parameterized unit tests (TEST_P) Created: 06/Nov/23  Updated: 08/Nov/23

Status: Backlog
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: James Harrison Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Service Arch
Participants:

 Description   

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.



 Comments   
Comment by James Harrison [ 08/Nov/23 ]

Thanks jason.chan@mongodb.com!

FWIW, the PoC above intentionally matches behaviour and user-visible macro/class names with GTest (following the existing trend), so it wouldn't add extra difficulty for PM-2926 if/when it is persued.

Generated at Thu Feb 08 06:50:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.