Skip to content
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 access to source element annotations for TempDirFactory #3394

Merged

Conversation

scordio
Copy link
Contributor

@scordio scordio commented Jul 13, 2023

Overview

Closes #3390.


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


Definition of Done

@scordio scordio force-pushed the gh-3390_TempDirFactory_source_element branch from 0eff9fd to afccc61 Compare July 13, 2023 20:53
@scordio
Copy link
Contributor Author

scordio commented Jul 14, 2023

@marschall could you please point me to some real-life usage so that I can put together the corresponding tests?

memoryfilesystem is already in the test scope so we should be able to stay as close as possible to what you have in mind.

@sbrannen
Copy link
Member

could you please point me to some real-life usage so that I can put together the corresponding tests?

How about a custom @TempDirPrefix(<String value()>) annotation that your custom TempDirFactory uses to look up the prefix?

@scordio scordio force-pushed the gh-3390_TempDirFactory_source_element branch from 36290a2 to 759fa79 Compare July 15, 2023 08:33
Copy link
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.

Looking good! Please add tests accessing getAnnotatedElement for a field and parameter as discussed above.

@scordio scordio force-pushed the gh-3390_TempDirFactory_source_element branch from 759fa79 to 6508ae7 Compare July 15, 2023 14:56
@scordio
Copy link
Contributor Author

scordio commented Jul 15, 2023

I assume this change doesn't require an entry in the release notes, right?

@scordio scordio force-pushed the gh-3390_TempDirFactory_source_element branch from 59278b0 to b878c90 Compare July 16, 2023 09:25
@scordio scordio requested review from sbrannen and marcphilipp July 16, 2023 09:35
@scordio scordio marked this pull request as ready for review July 16, 2023 09:35
@marschall
Copy link
Contributor

@marschall could you please point me to some real-life usage so that I can put together the corresponding tests?

memoryfilesystem is already in the test scope so we should be able to stay as close as possible to what you have in mind.

Sure, here's the implementation of the factory, built against this PR

https://github.com/marschall/memoryfilesystem-junit-provider/blob/master/src/main/java/com/github/marschall/memoryfilesystem/junit/MemoryFileSystemTempDirFactory.java

Here's the meta-annotation

https://github.com/marschall/memoryfilesystem-junit-provider/blob/master/src/main/java/com/github/marschall/memoryfilesystem/junit/WindowsMemoryTempDir.java

Here's the integration test

https://github.com/marschall/memoryfilesystem-junit-provider/blob/master/src/test/java/com/github/marschall/memoryfilesystem/junit/WindowsMemoryTempDirTests.java

A test may look something like this.

marschall@eb58e90

This code is quite rushed and can obviously be improved. First would probably be the names. A extension of the existing test rather than copy and pasting would probably be next. Feel free to cherry pick and improve upon it.

@marcphilipp
Copy link
Member

I assume this change doesn't require an entry in the release notes, right?

If we're going directly to GA, we don't need an extra entry. I'm considering doing an RC2 release. If I decide to go for that, I'll add a release note entry myself.

@scordio
Copy link
Contributor Author

scordio commented Jul 16, 2023

A test may look something like this.

marschall@eb58e90

Thanks, I've improved the existing test along these lines in ea6d11d.

@scordio
Copy link
Contributor Author

scordio commented Jul 16, 2023

All feedback applied, @marcphilipp and @sbrannen. I don't expect further changes unless you see something.

Some jobs are failing but it seems to be a remote issue:

* What went wrong:
A problem occurred configuring root project 'junit5'.
> Could not resolve all files for configuration ':classpath'.
   > Could not download nohttp-0.0.11.jar (io.spring.nohttp:nohttp:0.0.11)
      > Could not get resource 'https://plugins.gradle.org/m2/io/spring/nohttp/nohttp/0.0.11/nohttp-0.0.11.jar'.
         > Could not GET 'https://jcenter.bintray.com/io/spring/nohttp/nohttp/0.0.11/nohttp-0.0.11.jar'. Received status code 502 from server: Bad Gateway

Lastly, I left unchecked the release notes task based on #3394 (comment).

@marcphilipp marcphilipp merged commit acb6e65 into junit-team:main Jul 17, 2023
@marcphilipp
Copy link
Member

@scordio Thanks tons for the quick turnaround on this! 👍

@scordio scordio deleted the gh-3390_TempDirFactory_source_element branch July 17, 2023 06:51
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.

Provide TempDirFactory access to the source element (parameter or field)
4 participants