Skip to content

Support programmatic registration of resource locks#3889

Merged
marcphilipp merged 30 commits intojunit-team:mainfrom
vdmitrienko:#2677_add_exclusive_resource_programmatically
Oct 7, 2024
Merged

Support programmatic registration of resource locks#3889
marcphilipp merged 30 commits intojunit-team:mainfrom
vdmitrienko:#2677_add_exclusive_resource_programmatically

Conversation

@vdmitrienko
Copy link
Copy Markdown
Contributor

@vdmitrienko vdmitrienko commented Jul 16, 2024

Solves: #2677

Overview

Introduce adding shared resources programmatically via @ResourceLock(providers = ...) attribute
which accepts an array of one or more classes implementing ResourceLocksProvider interface.

It allows to add resources in runtime (immediately before starting execution on the engine level).

Resources can be distributed based on any test class / nested test class / test method attributes (e.g. package name, class / method name etc.) or any other user logic.

This approach serves as a more flexible and less verbose alternative for cases in which:

  • adding lots of @ResourceLock(value, mode) annotations manually may be inconvenient;
  • shared resources are not known until runtime.

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@vdmitrienko vdmitrienko marked this pull request as draft July 17, 2024 06:39
@vdmitrienko vdmitrienko changed the title Draft: Implement adding ExclusiveResource programmatically. Implement adding ExclusiveResource programmatically. Jul 17, 2024
@vdmitrienko vdmitrienko changed the title Implement adding ExclusiveResource programmatically. Introduce adding 'shared resources' programmatically Aug 6, 2024
@vdmitrienko vdmitrienko marked this pull request as ready for review August 8, 2024 06:52
@marcphilipp marcphilipp linked an issue Aug 9, 2024 that may be closed by this pull request
Copy link
Copy Markdown
Member

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very promising! Sorry for the late request to change the API.

Comment thread documentation/src/docs/asciidoc/user-guide/writing-tests.adoc Outdated
@vdmitrienko
Copy link
Copy Markdown
Contributor Author

Hi @marcphilipp
Maybe you have any updates regarding this PR?

Comment thread documentation/src/docs/asciidoc/user-guide/writing-tests.adoc Outdated
Comment thread documentation/src/docs/asciidoc/user-guide/writing-tests.adoc Outdated
@vdmitrienko
Copy link
Copy Markdown
Contributor Author

Thanks! I'll take it from here.

Thank you!
This was my first contribution, and it was very interesting and valuable experience.

@marcphilipp marcphilipp changed the title Introduce adding 'shared resources' programmatically Allow determining exclusive resources programmatically Oct 7, 2024
@marcphilipp marcphilipp merged commit 8e9094d into junit-team:main Oct 7, 2024
@sbrannen sbrannen changed the title Allow determining exclusive resources programmatically Support programmatic registration of resource locks Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support programmatic registration of resource locks

3 participants