RFR: 7903965: Fix Launching Tests from Context Menu [v5]
Oleksii Sylichenko
duke at openjdk.org
Tue Mar 11 16:35:53 UTC 2025
> Currently, there is an issue with running TestNG/JUnit tests when using the context menu on the editor tab. TestNG/JUnit intercepts the test execution from JTReg.
>
> After fixing this issue, I decided to extend the fix to cover all potential use cases of the context menu.
>
> As part of this pull request, I propose enhancing the process of running tests via the context menu. The context menu can be used in the following cases:
>
> - Editor tab
> - File in the project tree
> - Directory in the project tree
> - Any location within a file
>
> The current changes automatically determine what needs to be executed:
>
> - Directory
> - File
> - Method
>
> Additionally, the issue with intercepting test execution through Application, TestNG, and JUnit configurations when using the context menu on the editor tab has been fixed.
>
> # Summary
>
> - Ensure that run configuration priority is no longer lost to Application, TestNG, or JUnit setups when launching via the context menu.
> - Fix run configuration created via the context menu: find and launch the proper test element, depending on the current PSI element.
> - Improve the logic for comparing existing run configurations with newly generated ones.
> - Add JUnit plugin in the dependencies.
>
> # Detailed changes
>
> ## Add JUnit plugin into dependencies
> - build.gradle
> - plugin.xml
>
> ## JTRegClassConfigurationProducer.java
> - Refactor `setupConfigurationFromContext`:
> - Move the check for whether a file can be run to `JTRegUtils#isRunnableByJTReg`.
> - Allow this method to create configurations for directories as well.
> - Implement `preventRunPriorityLoss` to prevent priority takeover by other run configuration types (Application, TestNG, JUnit) under certain conditions.
> - Replace the use of the current PSI element for generating names and querying run configurations with the specific element intended for execution.
> - Implement `preventRunPriorityLoss`.
> - Add Javadoc for `nameForElement`.
>
> ## JTRegConfigurationProducer.java
> - Fix logic in `isConfigurationFromContext` for checking if two configurations are identical:
> - Replace the use of the current PSI element for queries with the exact element intended for execution.
> - Compare string-typed configuration parameters using a "not-nullify" approach (`null == ""`).
> - Implement `findExactRunElement` to locate the specific PSI element for execution among the current element’s parents.
> - Add a JUnit check to the `shouldReplace` method.
>
> ## JTRegUtils.java
> - Add a predicate to compare two strings ...
Oleksii Sylichenko has updated the pull request incrementally with four additional commits since the last revision:
- 7903965: Fix Launching Tests from Context Menu
- merge the code of the dir and file config producers into a parent config producer
- prevent configuration creation when multiple files or directories are selected
- delete class config producer
- delete dir config producer
Use PsiClass/PsiMethod instead of PsiIdentifier:
- `findExactRunElement()`
- `nameForElement()`
- `getQuery`
- add javadoc for `JTRegUtils.isThirdPartyTestElement`
- remove `JTRegUtils.isEqualNullAsEmpty`
- replace `JTRegUtils.isEqualNullAsEmpty` with `Comparing.strEqual`
-------------
Changes:
- all: https://git.openjdk.org/jtreg/pull/252/files
- new: https://git.openjdk.org/jtreg/pull/252/files/42b93ee8..fc97ec59
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jtreg&pr=252&range=04
- incr: https://webrevs.openjdk.org/?repo=jtreg&pr=252&range=03-04
Stats: 397 lines in 5 files changed: 119 ins; 248 del; 30 mod
Patch: https://git.openjdk.org/jtreg/pull/252.diff
Fetch: git fetch https://git.openjdk.org/jtreg.git pull/252/head:pull/252
PR: https://git.openjdk.org/jtreg/pull/252
More information about the jtreg-dev
mailing list