Description
openedon Nov 3, 2017
Issue
Extension methods all have ExtensionContext
which provides us many useful information like displayname
, method
or tags
. This helps in writing custom test reports.
What I'm missing is a way to get argument instances of a @ParameterizedTest
. When not running tests extended by a ParameterResolver
using ExtensionContext.Store
you can only make a workaround to get a clue of what arguments were used for the test:
- Filter displayname (objects need to override
toString()
for important informations) - get values from annotations
If parameters are simple strings, integers etc. there is no problem when parsing displayname. The problem starts when one of the parameters is an object containing lots of informations. A new instance would have to be created when analyzing the test, but this doesn't garanty an object with exact the same content like in the test and might also lead to memory issues.
Most simple way is to reimplement Parameterized Test Template, extend from each class, catch resolved parameters and store them directly in ExtensionContext.Store, but I'm not a fan of writing Wrapper classes for such small extensions in existing codes.
Possible Suggestions
- Provide a method
Arguments[] ExtensionContext.getArguments()
orList<Arguments> ExtensionContext.getArguments()
which returns a list of all Arguments used for the test (empty list if no arguments were used). - Store arguments in
ExtensionContext.Store
with a predefined namespace in yourParameterizedTestParameterResolver
class (then there is no need to do it in customArgumentsProvider
classes) - Provide an Extension interface which is called between
BeforeTestExecutionCallback
and@Test
. As parameters it should haveExtensionContext
andArguments[]
.
Related Issues
Metadata
Assignees
Type
Projects
Status
Todo