jqwik-team / jqwik

Property-Based Testing on the JUnit Platform
http://jqwik.net
Eclipse Public License 2.0
575 stars 64 forks source link

Add proximity property to `AddLifecycleHook` #398

Open jlink opened 2 years ago

jlink commented 2 years ago

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.

adam-waldenberg commented 2 years ago

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 :)