-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add resource container selector resolver #3718
base: main
Are you sure you want to change the base?
Add resource container selector resolver #3718
Conversation
As a follow up for junit-team#3630 and junit-team#3705 this adds a `addResourceContainerSelectorResolver()` method to `EngineDiscoveryRequestResolver.Builder` analogous to `addClassContainerSelectorResolver()`. Points of note: * As classpath resources can be selected from packages, the package filter should also be applied. To make this possible the base path of a resource is rewritten to a package name prior to being filtered. * The `ClasspathResourceSelector` now has a `getClasspathResource` method. This method will lazily try to load the resource if not was not already provided when discovering resources in a container. * `selectClasspathResource(Resource)` was added to short circuit the need to resolve resources twice. And to make it possible to use this method as part of the public API, `ReflectionSupport.tryToLoadResource` was also added.
…-container-selector-resolver
...form-engine/src/main/java/org/junit/platform/engine/discovery/ClasspathResourceSelector.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ResourceFilter.java
Outdated
Show resolved
Hide resolved
...main/java/org/junit/platform/engine/support/discovery/ResourceContainerSelectorResolver.java
Outdated
Show resolved
Hide resolved
…-container-selector-resolver
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScanner.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ResourceUtils.java
Outdated
Show resolved
Hide resolved
…-container-selector-resolver
Currently, there are two options: We briefly discussed the problem in the team. Do you have a concrete use case that would require solving the problem of having a machine-independent identifier for re-running a test based on a non-unique classpath resource? Otherwise, maybe we can move forward as-is and see if it actually becomes a problem? |
…r-selector-resolver
Haven't got any concrete examples in mind right now. So that seems reasonable. |
Overview
Resolve resource container selectors
As a follow up for #3630 and #3705 this adds a
addResourceContainerSelectorResolver()
method to
EngineDiscoveryRequestResolver.Builder
analogous toaddClassContainerSelectorResolver()
.Points of note:
As classpath resources can be selected from packages, the package
filter should also be applied. To make this possible the base path of
a resource is rewritten to a package name prior to being filtered.
The
ClasspathResourceSelector
now has agetClasspathResources
method. This method will lazily try to load the resources if not
already provided when discovering resources in a container.
selectClasspathResource(Set<Resource>)
was added to short circuit theneed to resolve resources twice. And to make it possible to use
this method as part of the public API,
ReflectionSupport.tryToLoadResources
was also added.I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations