-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Background
#1467 and #1178 added support for dynamic containers and tests specifying a custom test source via DynamicNode.getTestSourceUri()
.
These URI
s can be used to link dynamic tests and containers with a FileSource
, DirectorySource
or ClasspathResourceSource
.
These sources may optionally have an associated line and column number, which is indicated by using a query string in the URI
, such as line=23&column=12
.
Proposal
If a URI
has a classpath
scheme and a method=myMethodName
query string then TestFactoryTestDescriptor.fromUri(URI uri)
should create and return a MethodSource
.
Use cases
I initially encountered this when using @TestFactory
to run a test suite without switching engines. That's working (bar linking back to methods in test cases from the test tree in Eclipse), but it is not a compelling use case since suites are being addressed by #744.
However, I can envisage other cases where this would be useful, such as verifying consistent use of Hibernate annotations across Java beans. Previously I've written cumbersome custom PMD rules for this. Dynamic tests could link back to getters in the application source rather than unit tests.
Related issues
- Support classpath resource for custom test source in dynamic tests #1467
- DynamicTest should be able to provide tags and source information to TestDescriptor #1178
Deliverables
- ❌ Add support for creating a
MethodSource
for a dynamic test if the custom test sourceURI
uses theclasspath
scheme and amethod=myMethodName
query string. - Introduce support for converting from a URI of the form
method:<FQMN>
to aMethodSource
, where FQMN is the fully qualified method name. See the Javadoc forDiscoverySelectors.selectMethod(String)
for the supported formats for a FQMN. - Modify JavaDoc to explain supported
URI
schemas and query strings. -
Document in User Guide.will be addressed in Document URI TestSource support of dynamic tests in User Guide #1903 - Document in Release Notes.