-
-
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
Provide TempDirFactory
access to the source element (parameter or field)
#3390
Comments
That's an interesting proposal. However, if we want to have support for this... we'd better do it as a "last minute" addition for 5.10 GA. Otherwise, it will become more challenging to alter the @junit-team/junit-5, thoughts? |
TempDirFactory
access to the source element (parameter or field)
The corresponding Would that be enough? @marschall in case the team wants to proceed in this direction, would you like to compose such changes by yourself? Otherwise, I am happy to help with it. |
@scordio, thanks for volunteering. I also came to the conclusion that we could propagate the Path createTempDirectory(ExtensionContext context, AnnotatedElement sourceElement) throws Exception; (or switching the order of the However, it's not that straightforward. For example, if Thus, we would in fact have to come up with a solution similar to Furthermore, I'm not sure if this is a one-off feature. Disclaimer: I'm not sure, simply because I have not yet put enough thought into it. In any case, if we have to go to the extent of implementing and supporting something analogous to Thus, deciding what should be done requires a bit of research into the available options. @scordio, if you'd like to volunteer to research that, please do! |
Hi @sbrannen, sure, happy to research it further. Do you know roughly when 5.10 GA will be released? |
@scordio We were going to release it end of the week but we can postpone if need be |
Please don´t postpone just for me. I consider this a nice use-case and can live with breaking changes, especially for an experimental API. In the mean time I can use other workarounds like different factory classes or abstract factory classes. |
@sbrannen, thanks a lot for the pointers. Furthermore, the reading of #1345 helped me a lot in understanding the problem better.
I tried to follow your idea but I'm afraid I'm not familiar enough with all the features of JUnit to identify a suitable solution in this direction. For this reason, I'd like to try a slightly different approach and would be happy to hear your thoughts. My approach would be the following:
I'm not quite ready with a draft PR but I should be able to submit something in a couple of days. Two questions though:
|
You're welcome!
Yeah... that was a tricky one. 😱 Regarding I'm busy with other things at the moment, so I think @marcphilipp will be able to review your PR. |
This allows inspecting the declaration site of `@TempDir` in `TempDirFactory`. Resolves #3390.
I'm working on a
TempDirFactory
implementation based on my own memory file system implementation over at marschall/memoryfilesystem-junit-provider. One of the features I would like to offer is configuration, allowing the user more control over the kind of file system they get (Windows, Unix, macOS, …). I imagine this configuration to be done through additional annotations on the element annotated with@TempDir
, something like this(this can me made more compact with the help of meta-annotations)
For this to work, the
TempDirFactory
implementation needs access to this annotated element. UnfortunatelyTempDirFactory
is only passed anExtensionContext
which only gives access to the test, not the element (method or field) annotated with@TempDir
. What is needed is something likeParameterContext
inParameterResolver
.Deliverables
TempDirFactory
API to give access to annotated source elementThe text was updated successfully, but these errors were encountered: