-
-
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
Support MethodSource as custom test source in dynamic tests #1850
Comments
Thanks for raising the issue. I think that would make sense. @junit-team/junit-lambda WDYT? |
Tentatively assigned to 5.5 M2 for team discussion. |
Team Decision: Although we do not foresee that many developers would use such a Introduce support for converting from a URI of the form Ideally, the new Note that we will not reuse the |
This issue is currently "up for grabs". |
FYI: the implementation of this feature should internally delegate to |
@sbrannen If no one is picked up this. I would like to pick this issue & submit PR. |
@gopinath-langote, you're the first to volunteer. So feel free to submit a PR. |
@gopinath-langote did you get a chance to work on this? If not, I can pick it up if you don't mind? |
@ielatif Feel free to pick it up, if you're still interested. |
@marcphilipp Yes I still do.
We can add a new class ex: MethodFinder/MethodExtractor in org.junit.jupiter.engine.descriptor to implement the logic of extracting a method from URI Or may be reuse org.junit.jupiter.engine.discovery.MethodFinder and add a new method to it |
@marcphilipp @sbrannen sorry for the late reply. I did not get time to work on this. Someone else can pick this issue. I will look for the other one. Thanks, |
@gopinath-langote I am on it. Thanks |
@gopinath-langote No worries, thanks for letting us know! |
URIs for test methods are now as described in pending JUnit issue for supporting MethodSource as custom test source in dynamic tests. This should be verified manually once the JUnit issue has been resolved. See junit-team/junit5#1850.
… to a MethodSource Introduce support for converting from a URI of the form method:<FQMN> to a MethodSource, where FQMN is the fully qualified method name. See the Javadoc for DiscoverySelectors.selectMethod(String) for the supported formats for a FQMN. Closes junit-teamgh-1850
… to a MethodSource Introduce support for converting from a URI of the form method:<FQMN> to a MethodSource, where FQMN is the fully qualified method name. See the Javadoc for DiscoverySelectors.selectMethod(String) for the supported formats for a FQMN. Closes junit-teamgh-1850
Tentatively slated for 5.5 RC1 since PR #1895 has been submitted. |
@sbrannen @marcphilipp we have to update issue Deliverables to reflect the changes. |
Done 👍 |
JUnit 5.5.0-RC1 adds support for MethodSource URIs. See junit-team/junit5#1850
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 aFileSource
,DirectorySource
orClasspathResourceSource
.These sources may optionally have an associated line and column number, which is indicated by using a query string in the
URI
, such asline=23&column=12
.Proposal
If a
URI
has aclasspath
scheme and amethod=myMethodName
query string thenTestFactoryTestDescriptor.fromUri(URI uri)
should create and return aMethodSource
.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
Deliverables
MethodSource
for a dynamic test if the custom test sourceURI
uses theclasspath
scheme and amethod=myMethodName
query string.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.URI
schemas and query strings.Document in User Guide.will be addressed in Document URI TestSource support of dynamic tests in User Guide #1903The text was updated successfully, but these errors were encountered: