-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[WIP] Introduce extension API for accessing arguments passed to tests #1614
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
[WIP] Introduce extension API for accessing arguments passed to tests #1614
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1614 +/- ##
============================================
+ Coverage 91.94% 91.94% +<.01%
- Complexity 3491 3496 +5
============================================
Files 321 322 +1
Lines 8329 8342 +13
Branches 722 723 +1
============================================
+ Hits 7658 7670 +12
- Misses 500 501 +1
Partials 171 171
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Regarding the points you mentioned...
Naming of the callback.
We cannot call it "Parameterized", since the core extension API knows nothing about parameterized tests.
Such a callback should be generic for use with the invocation of any testable method.
Currently, the arguments are resolved twice via the DefaultParameterResolver. It would be better to do this once (and pass a copy to the callback) but this would require a change to the ExecutableInvoker API. I'm happy to do this but thought I'd wait from feedback first.
We most definitely cannot resolve parameters twice for a given invocation since doing so may cause undesired side effects in extensions that implement ParameterResolver
.
Also, I'm not sure that we want to (or need to) extract such a DefaultParameterResolver
from ExecutableInvoker
.
So, please rework your PR accordingly.
Cheers,
Sam
Please see my notes in #1139 (comment) as well, especially the last paragraph. |
Thanks for the feedback Sam. I figured as much about the naming. I'll just revert to ArgumentsProcessor.
I did miss that bit about the flag at the end of that comment, however wouldn't that mean that the Isn't this what the It seems that we'd be adding to the responsibilities of the Ultimately my thinking was that for test methods (which are only called from Cheers Paul |
private void resolveParametersAndInvokeTestMethod(JupiterEngineExecutionContext context, | ||
DynamicTestExecutor dynamicTestExecutor, ThrowableCollector throwableCollector) { | ||
ExtensionRegistry registry = context.getExtensionRegistry(); | ||
Object[] arguments = parameterResolver.resolveParameters(getTestMethod(), Optional.empty(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test instance cannot be "empty". You'll have to retrieve that and pass it on like in invokeTestMethod()
.
import org.junit.platform.commons.logging.LoggerFactory; | ||
import org.junit.platform.commons.util.Preconditions; | ||
|
||
public class DefaultParameterResolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this not an implementation of ParameterResolver
, we cannot call it DefaultParameterResolver
.
Instead, we should name it something like ParametersResolver
. The "s" is admittedly easy to overlook. So maybe we'll come up with something better later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you're agreeing to extract this as a class now?
Anyway, I've pushed some more changes with what I think you're saying.
Rename callback to ArgumentsProcessor. Rename DefaultParameterResolver to ParametersResolver. Now resolving test method parameters only once, and passing a copy to the ArgumentsProcessor. Test method is called using original resolved parameters via new method in ExecutableInvoker.
Blocked by #1139 (comment). |
This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions. |
This pull request has been automatically closed due to inactivity. If you are still interested in contributing this, please ensure that it is rebased against the latest branch (usually |
Overview
Addresses : #1139
Adding a BeforeParameterizedTestExecutionCallback to be called prior to test method execution with a copy of the actual test arguments.
Points for discussion:
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations