Open georgevdd opened 1 year ago
(We also have this FR internally.)
The idea of an implementation would be to make absl.testing.absltest.TestLoader
aware of parameterized, and evaluate the parameterized test cases there. It needs to continue support test filtering, test order randomization.
Enumeration of the cases for a parameterized test method in an
absl.testing.parameterized.TestCase
is eager: it happens at the point where the class is defined.Under normal circumstances, this is before
googletest.main()
has been called, meaning that the sequence of cases cannot depend on the values of flags defined byabsl.flags
(or, indeed, on anything that is not meaningfully defined at the point that theTestCase
class is created).Thus, the following structure will not work:
Possible Fix
Either of two changes could fix this: making command-line flag parsing more eager, or making test case enumeration lazier. The latter seems simpler.
Each of
parameterized.parameters()
,parameterized.named_parameters()
,parameterized.product()
and so on could be widened to accept, in addition to the types that it currently accepts, acallable
that returns one of those types. If it finds its argument is callable, it could defer enumeration of the cases until some point after command-line flags have been parsed.Then the above snippet could be amended: