jqwik icon indicating copy to clipboard operation
jqwik copied to clipboard

Add proximity property to `AddLifecycleHook`

Open jlink opened this issue 2 years ago • 1 comments

Testing Problem

Motivated by https://github.com/jlink/jqwik/issues/395 it would be useful to be able to specify the proximity of Lifecycle hooks not only at implementation time - through overriding the proximity method - but also at specification time. This would for example allow to influence the order in which lifecycle hooks are executed in regard to lifecycle methods (@BeforeProperty etc.)

Suggested Solution

Implement attribute proximity to AddLifecycleHook annotation which will translate the proximity to the hooks proximity.

Discussion

This is not as straightforward as it sounds, because different hooks have different proximities. E.g. AroundPropertyHook has just aroundPropertyProximity() and AroundContainerHook has three different proximity values. Moreover, a single lifecycle hook implementation can implement more than one lifecycle hook. Therefore, a single attribute like proximity may not suffice.

jlink avatar Oct 25 '22 06:10 jlink

This is true... Maybe something like a @HookProximity annotation is the way to go in order to set it. If no hook is specified it could, by default set a proximity for all of them.... and if it can be set on both method and on the class it would allow for pretty great control.

It suddenly got a lot more complicated though :)

adam-waldenberg avatar Oct 25 '22 10:10 adam-waldenberg