Constructor parameter resolution order for PER_CLASS vs PER_METHOD
The timing of constructor parameter resolution relative to lifecycle callbacks differs between PER_CLASS and PER_METHOD.
Specifically:
With
PER_CLASS, constructor parameters are resolved beforebeforeAll()andbeforeEach().With
PER_METHOD, constructor parameters are resolved afterbeforeAll()but beforebeforeEach().
This can complicate extension development. For example, a ParameterResolver that depends on resources initialized in BeforeAllCallback can work with PER_METHOD but fail with PER_CLASS.
I couldn’t find an explicit explanation of this ordering in the documentation. Could the lifecycle documentation show where test instance creation and constructor parameter resolution occur for each mode?
Perhaps it could also be made uniform between modes?
Source: junit-team/junit-framework