Skip to content

Provide TempDirFactory access to the source element (parameter or field) #3390

@marschall

Description

@marschall

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

@TempDir(factory = MemoryFileSystemTempDirFactory.class)
@MemoryTempDirType(WINDOWS)
Path tempDirectory;

(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. Unfortunately TempDirFactory is only passed an ExtensionContext which only gives access to the test, not the element (method or field) annotated with @TempDir. What is needed is something like ParameterContext in ParameterResolver.

Deliverables

  • extend TempDirFactory API to give access to annotated source element

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions