Refactor reflection responsibilities across TestNG modules
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading ReflectionRecipes, ReflectionHelper, ClassHelper, and the testng-reflection-utils and testng-core module boundaries. The first proposed slice is a type-assignability utility with exhaustive primitive-conversion tests, followed by delegation from ReflectionRecipes. Done means the utility owns generic type logic while existing behavior remains covered and the broader migration plan is agreed.
Written by the indexing model from the issue text.
Description
Context
While working on #3362, I noticed that reflection-related responsibilities are currently spread across three modules:
- "testng-reflection-utils" with "ReflectionHelper"
- "testng-core" with "ReflectionRecipes" and the method matchers
- "testng-core-api" with "ClassHelper"
I think this makes the boundaries difficult to understand and has led to generic Java reflection/type logic being mixed with TestNG-specific parameter matching and injection logic.
For example, "ReflectionRecipes" currently mixes:
- generic type assignability and primitive widening;
- method/constructor parameter helpers;
- DataProvider argument matching;
- TestNG native parameter injection.
Similarly, "ClassHelper" mixes generic class loading/method discovery with TestNG-specific factory and XML-related behavior.
Proposed direction
I would like to make "testng-reflection-utils" the single owner of generic Java reflection utilities.
The rule would roughly be:
«"testng-reflection-utils" knows what Java allows; "testng-core" knows what TestNG wants to do with it.»
"testng-reflection-utils"
Keep all generic, TestNG-independent functionality here, for example:
org.testng.internal.reflect
├── ReflectionHelper
├── TypeUtils / TypeAssignability
└── ClassLoadingHelper
This would include:
- type assignability;
- primitive/wrapper handling;
- primitive widening rules;
- class loading;
- method hierarchy/discovery;
- generic annotation/reflection helpers.
Ideally, this module should not depend on TestNG domain types.
"testng-core"
The current classes under "org.testng.internal.reflect" such as:
DataProviderMethodMatcher
DirectMethodMatcher
ArrayEndingMethodMatcher
InjectableParameter
MethodMatcher*
are not really generic reflection utilities. They implement TestNG parameter matching/injection semantics.
I would move them to something like:
org.testng.internal.parameters
and split the TestNG-specific parts of "ReflectionRecipes" into concepts such as:
ParameterMatcher
ParameterInjector
"ReflectionRecipes" could then disappear entirely.
"testng-core-api"
"ClassHelper" should probably not be moved as-is either.
Its generic parts (class loading, method discovery, etc.) could move to "testng-reflection-utils", while TestNG-specific operations such as factory discovery or "XmlSuite"/"XmlTest" handling remain in "testng-core-api" under more specific classes.
Since "ClassHelper" is public even though it is under "org.testng.internal", we could keep delegating/deprecated methods temporarily if compatibility is a concern.
Suggested incremental migration
I would avoid doing this as one large refactoring.
- Introduce a small type-assignability utility in "testng-reflection-utils", with exhaustive primitive conversion tests, and make "ReflectionRecipes" delegate to it.
- Extract "exactMatch", "lenientMatch" and "matchArrayEnding" into parameter-matching code in "testng-core".
- Extract "filter", "inject" and "canInject" into parameter-injection code.
- Remove "ReflectionRecipes".
- Split the generic responsibilities out of "ClassHelper".
- Eventually make "org.testng.internal.reflect" belong exclusively to "testng-reflection-utils".
This should give us a clearer module boundary without introducing another reflection library or requiring a large rewrite.
@krmahadevan, what do you think about this direction?
Drafted by ChatGPT under Julien's supervision.
- Dominant language
- Java
- Stars
- 2.1k
- Forks
- 1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testng-team/testng
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#3672 ·
Maintainers usually reply within 1 day
-
`setXmlSuites` skips a `<suite-file>` that cannot be read, but `setTestSuites` stops the runPossibly taken @sean0407 claimed this 49 days ago. Openarea: xml suites priority: medium roadmap: optional
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#3571 ·
Maintainers usually reply within 1 day
-
area: xml suites contribution: help wanted effort: medium priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
testng-team/testng#2641 · 2 comments ·
Maintainers usually reply within 1 day
-
Broken linksOpencontribution: good first issue effort: low priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#2449 · 6 comments ·
Maintainers usually reply within 1 day
-
area: dependency injection area: public api contribution: good first issue effort: low priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
testng-team/testng#2212 · 4 comments ·
Maintainers usually reply within 1 day
All issues in testng-team/testng
Similar issues
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eclipse-edc/IdentityHub#1296 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
cloudfoundry/uaa#4194 ·
Maintainers usually reply within 1 day
-
area: ui priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
tetsuji16/microProject#1721 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
[Bug] [BanyanDB] timestamp.ParseDuration silently drops everything after "d"Possibly taken @soujasK claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
apache/skywalking#14287 ·
Maintainers usually reply within 1 day