-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement include and exclude filtering when calling registerAutoDetectedExtensions in MutableExtensionRegistry #4120
Implement include and exclude filtering when calling registerAutoDetectedExtensions in MutableExtensionRegistry #4120
Conversation
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
There are a few points we need to discuss further.
|
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
39f138a
to
15467ad
Compare
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
15467ad
to
4a896f1
Compare
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
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.
We're getting there but I found a few more things. 😅
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/JupiterConfiguration.java
Show resolved
Hide resolved
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/JupiterConfiguration.java
Outdated
Show resolved
Hide resolved
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
Yes, I think that's how it generally works.
Yes, I think that's a good idea. We should use |
When used on the module path, `ServiceLoader` determines its calling module from the stack and check whether its module descriptor contains a `uses` directive for the service type. If not, it will throw an exception. Therefore, `ServiceLoader.load` needs to be called directly in the module using the service but the filtering can still occur in junit-platform-commons.
@YongGoose I sent a PR to your PR branch: YongGoose#1 Initially, I wanted to reuse the new Please merge my PR into your branch so we can incorporate its commits in this PR. I didn't want to push to your PR branch directly to avoid conflicts. |
…cution-listener-instantiation Avoid instantiating deactivated TestExecutionListeners
@marcphilipp I understand the issue with ServiceLoader.load's caller validation and the resulting limitations in junit-platform-commons. I've reviewed the solution you proposed (YongGoose/junit5@d5a3511), and it seems like a good approach. I'll merge the PR into my branch as requested. |
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
@YongGoose Please let me know when you're done with your changes and I should re-review. |
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
edce1d6
to
02c91b5
Compare
jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/ExtensionRegistryTests.java
Outdated
Show resolved
Hide resolved
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
[[automatic-extension-registration-pattern-matching]] | ||
===== Pattern Matching Syntax | ||
|
||
Pattern matching syntax is used to automatically detect and register extensions. Here are some examples of pattern matching syntax: | ||
|
||
- `*`: includes all extensions. | ||
- `org.junit.*`: includes every extension under the `org.junit` base package and any of its subpackages. | ||
- `*.MyExtension`: includes every extension whose simple class name is exactly `MyExtension`. | ||
- `*System*`: includes every extension whose FQCN contains `System`. | ||
- `*System*, *Dev*`: includes every extension whose FQCN contains `System` or `Dev`. | ||
- `org.example.MyExtension, org.example.TheirExtension`: includes extensions whose FQCN is exactly `org.example.MyExtension` or `org.example.TheirExtension`. | ||
|
||
> **Note**: A class that matches both an inclusion and exclusion pattern will be excluded. |
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.
We should instead just link to the running-tests-config-params-deactivation-pattern
.
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.
I'm not very skilled at documentation work yet 😅
[[automatic-extension-registration-pattern-matching]]
===== Pattern Matching Syntax
Refer to <<running-tests-config-params-deactivation-pattern>> for details.
Would this change be fine?
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.
I haven't checked the history but I think the main reason this indirection exists in the other places is because we didn't want to break existing links. Since we're introducing new content here, I think we can simplify and link to the target section directly, i.e. without introducing another subsection.
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.
I made this change in 13c1b19
...upiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java
Outdated
Show resolved
Hide resolved
…tension/MutableExtensionRegistry.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
Thank you very much for correcting my mistakes. 6e5b161 |
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.
Please also add integration tests for this to ExtensionRegistryTests
. It currently verifies that ServiceLoaderExtension
gets registered. If you add another one, you should be able to configure the two new config params in jupiter-tests/src/test/resources/junit-platform.properties
so that one gets included and the other excluded.
/** | ||
* A blank pattern used for class name filtering: {@value} | ||
* | ||
* <p>This constant is used to represent an empty or blank pattern in class name filtering operations. | ||
* | ||
* @see ClassNamePatternFilterUtils#BLANK | ||
*/ | ||
public static final String BLANK = ClassNamePatternFilterUtils.BLANK; | ||
|
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.
It seems weird to me to introduce a constant for an empty string here. Let's keep it internal and remove it from here, ok?
No worries, that always requires a lot of context. I took a stab at it and pushed a commit to your branch. |
I couldn't work on this because I had an interview this week. I apologize for the delay. Can I proceed with the integration test after mocking
I tried implementing it using |
No worries! I hope the interview went well!
LGTM 👍 |
After much consideration, I’ve concluded that mocking the However, the
Additionally, through debugging, I confirmed that the intended
|
Thank you as always. |
Issue: junit-team#3717 Signed-off-by: yongjunhong <kevin0928@naver.com>
…xtensions-in-junit' into feature/enable-specific-global-extensions-in-junit
I made this change in ec13b6d ! |
@YongGoose Thank you for your contribution! I improved a few mostly minor things in the last few commits. |
fix #3717
Overview
This PR enables the activation of specific global extensions in JUnit Jupiter.
I've already worked on this in my personal repository, and since there’s a large amount of code changes, I decided to split it into two PRs.
YongGoose@a2ef07f
I plan to proceed in the following two ways.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations