-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Currently the lifecycle for an injected entity is hardcoded by the supplier, but for some entity types like realms, clients, and users it should be possible to configure the lifecycle within the test.
We should support global, class, or method as lifecycles.
If not specified the lifecycle should be defined by the supplier. For example the default for the realm supplier is class, but it should be possible in a given test to clear that the realm can be re-used:
@TestRealm(lifecycle = global)
RealmResource realmOr, even if the test needs the realm to be re-created per-test method that should also be possible:
@TestRealm(lifecycle = method)
RealmResource realmSome thought should be given to the fact that when deleting a parent resource (like a realm) it is not needed to also deleted the child resource (for example client) separately. For example if both realm and clients have the same lifecycle only the realm should be explicitly deleted. This can potentially be handled by supplier by telling them whether or not the parent will be deleted at the same time. This optimisation can be done in a follow-up issue.