Variadic support for #[TestWith] attribute #5163
Labels
feature/data-provider
Data Providers
feature/metadata/attributes
feature/metadata
Issues related to attributes and annotations
type/enhancement
A new idea that should be implemented
Loving PHPUnit 10, thank you so much for it! I've switched a lot of my
@dataProvider
annotations to use the#[TestWith]
attribute, but I have found the fact that it takes an array of parameters rather than variadic parameters to be awkward. For example, I think this is cleaner:...than this:
...because the former almost looks like an invocation of the test method, which to me feels intuitive. I feel the latter looks like you're passing in array as a parameter. Since
TestWith::__construct()
does not take in any other parameters, I think it would be a better developer experience to take in a variadic parameter instead. Obviously, this would be a breaking change, which might mean we should use a new attribute instead. Using a variadic parameter would also complicate supporting a feature such as named data sets. I'm curious what your thoughts are on this and whether we should support variadic parameters or introduce a new attribute to prevent the breaking change. If so, I'll contribute a pull request.I should note that NUnit and xUnit both use the variadic parameter approach.
The text was updated successfully, but these errors were encountered: