Bug 343129 - [JUnit] Navigation to/running single test method containing spaces does not work
Summary: [JUnit] Navigation to/running single test method containing spaces does not work
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P5 normal with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
: 443581 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-18 06:17 EDT by Sergey Alaev CLA
Modified: 2020-02-11 01:53 EST (History)
9 users (show)

See Also:
markus.kell.r: review-


Attachments
Groovy JUnit4 test class illustrating the problem (117 bytes, application/octet-stream)
2011-04-18 06:19 EDT, Sergey Alaev CLA
no flags Details
Patch to added support for method names with spaces (8.75 KB, patch)
2014-11-28 23:11 EST, Wendell Beckwith CLA
no flags Details | Diff
Patch to added support for method names with spaces (8.75 KB, patch)
2014-11-29 16:56 EST, Wendell Beckwith CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Alaev CLA 2011-04-18 06:17:40 EDT
Build Identifier: 20100917-0705

Double-click on test method containing spaces in test pane results in 'method not found' message. Selecting method name containing spaces and pressing 'run' starts entire test class, not selected test method.

Java method names containing spaces are valid and can be used by Groovy and/or frameworks like Spock http://code.google.com/p/spock/

Reproducible: Always

Steps to Reproduce:
1. install eclipse groovy plugin http://groovy.codehaus.org/Eclipse+Plugin
2. create simple junit4 test with test method: void "test test"() {}
3. Run it and try to navigate to test method from junit pane.
Comment 1 Sergey Alaev CLA 2011-04-18 06:19:12 EDT
Created attachment 193475 [details]
Groovy JUnit4 test class illustrating the problem
Comment 2 Markus Keller CLA 2011-04-19 09:48:53 EDT
Java method names <= 1.6 can *not* contain spaces, see JLS3 3.8. However, the class file format maybe supports that.
Comment 3 Sergey Alaev CLA 2011-04-21 04:48:10 EDT
Yes, Java6 JVM allows spaces in method names:

http://jcp.org/aboutJava/communityprocess/final/jsr202/index.html

4.3.2 Unqualified Names
Names of methods, fields and local variables are stored as unqualified names.
Unqualified names must not contain the characters '.', ';', '[' or '/'. Method
names are further constrained so that, with the exception of the special method
names (ยง3.9) <init> and <clinit>, they must not contain the characters '<' or
'>'.
Comment 4 Sergey Alaev CLA 2011-04-21 06:24:41 EDT
Since Java is not the only language used to write junit tests it could be good to support everything JVM supports.
Comment 5 Noopur Gupta CLA 2014-09-09 11:25:02 EDT
*** Bug 443581 has been marked as a duplicate of this bug. ***
Comment 6 Wendell Beckwith CLA 2014-11-28 23:11:42 EST
Created attachment 249022 [details]
Patch to added support for method names with spaces

I have created the attached patch which add support for selecting a junit test method that may have spaces in the name (i.e. spock tests) and opening the associated editor to the method.
Comment 7 Wendell Beckwith CLA 2014-11-29 16:56:28 EST
Created attachment 249031 [details]
Patch to added support for method names with spaces

Oops, previous patch have some naming inconsistencies.
Comment 8 Wendell Beckwith CLA 2014-12-08 16:14:22 EST
OK, it's been over a week.  How about some commenting on the patch, please?  You know a little "It's the best thing ever!", "My eyes can't unsee the horror of this patch" or even it's "just meh."  Nonetheless, it the EF wants more contributors, we need interaction to help keep us going in the right direction.
Comment 9 Dani Megert CLA 2014-12-10 04:04:05 EST
(In reply to Wendell Beckwith from comment #8)
> OK, it's been over a week.  How about some commenting on the patch, please? 
> You know a little "It's the best thing ever!", "My eyes can't unsee the
> horror of this patch" or even it's "just meh."  Nonetheless, it the EF wants
> more contributors, we need interaction to help keep us going in the right
> direction.

Sorry, we have a milestone this week and hence pretty busy with that. Stay tuned!

Noopur, please review after M4 is out.
Comment 10 Markus Keller CLA 2015-02-24 15:04:09 EST
We won't add a preference for this. We rather have to understand the complete problem and then come up with a fix that just works fine in all cases. We should accept all characters that are valid as of the latest JVMS and then make sure we don't pass on non-Java method names if a consumer would throw exceptions.

Check the bugs mentioned in OpenTestAction#extractRealMethodName(TestCaseElement) and make sure the new implementation doesn't break those cases. If we run into cases where we end up with multiple possible method names, then we have to try them all until we find an existing method.

> // TODO How do I use the compliance levels to verify the jvm is 1.6+

The VM version doesn't matter. If you already have the method name, just try to work with it.
Comment 11 Eclipse Genie CLA 2015-11-30 10:43:17 EST
New Gerrit change created: https://git.eclipse.org/r/61579
Comment 12 Aurelien Pupier CLA 2015-11-30 11:49:31 EST
I proposed a gerrit change but it is not working yet completely.

The curren tissue is that in org.eclipse.jdt.internal.junit.ui.OpenTestAction.findMethod(IType), there is a check on JavaConventionsUtil.validateMethodName. In Eclipse, spaces in method names are not so it fails.

I see several options:
- remove the JavaConventionsUtil.validateMethodName , i think that there are no more real issue for that based on the very old commit and comment to related bug 127203. Launched AutomatedTestSuite and I have not more tests failing (yes I have 9 tests failing in my environment, need to take a look at that).
- Remove space in method name before calling JavaConventionsUtil.validateMethodName (ouch it's crappy but it is the simplest solution)
- Support spaces in Eclipse for method names --> seems to be a huge task

Any thoughts? Other options?
Which direction should we take to fix this issue?
Comment 13 Aurelien Pupier CLA 2015-12-01 03:33:59 EST
A forth option would be to have access to the real method name. it seems that the codee causing the issue is due to the fact that the "getName" is overriden somewhere to have a better display (based on some comments).
Need to search if this information is available or if it is loosed.
Comment 14 Eclipse Genie CLA 2020-02-11 01:53:10 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.