[
https://issues.apache.org/jira/browse/NETBEANS-4842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17202058#comment-17202058
]
Ratcash Developer commented on NETBEANS-4842:
---------------------------------------------
As you wish: [https://github.com/apache/netbeans/pull/2401]
> Go To Source broken with JUnit5 (and Gradle)
> --------------------------------------------
>
> Key: NETBEANS-4842
> URL: https://issues.apache.org/jira/browse/NETBEANS-4842
> Project: NetBeans
> Issue Type: Bug
> Components: projects - Gradle
> Reporter: Ratcash Developer
> Assignee: Laszlo Kishalmi
> Priority: Major
>
> JUnit4 and TestNG logs tested method names like:
> {noformat}
> testResults.MainTest > testA
> {noformat}
> However, JUnit5 adds the method's parameters, like this:
> {noformat}
> testResults.SecondaryTest > testA()
> testResults.SecondaryTest > testB()
> testResults.SecondaryTest > [1] 1, 2
> {noformat}
> The last one is a result of using
> {noformat}
> @ParametrizedTest
> @MethodSource("generate")
> public void testC(String a, String b) {
> // do something clever
> }
> {noformat}
> Such method names are not understood by the "Go To Source" functionality.
> For gradle projects a quick work-around may be the following change to clean
> method names:
> {code:java}
> ---
> a/java/gradle.java/src/org/netbeans/modules/gradle/java/api/output/LocationOpener.java
> +++
> b/java/gradle.java/src/org/netbeans/modules/gradle/java/api/output/LocationOpener.java
> @@ -80,7 +80,18 @@ public final class LocationOpener {
> }
> }
>
> - private int getMethodLine(final FileObject fo, final String methodName) {
> + private static String stripMethodParams(String methodNameWithParams) {
> + final int paramsIndex = methodNameWithParams.indexOf("(");
> + String cleanName = methodNameWithParams;
> + if (paramsIndex > 0) {
> + cleanName = methodNameWithParams.substring(0, paramsIndex);
> + }
> + return cleanName;
> + }
> +
> + private int getMethodLine(final FileObject fo, final String
> methodNameWithParams) {
> + String methodName = stripMethodParams(methodNameWithParams);
> final int[] line = new int[1];
> JavaSource javaSource = JavaSource.forFileObject(fo);
> if (javaSource != null) {
> {code}
> Certainly, it'd much better if the LocationOpener became able interpret and
> distinguish parameters and thus able navigate between overloaded methods as
> well.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists