This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 232519 - Run/Debug Focused Test Greyed Out
Summary: Run/Debug Focused Test Greyed Out
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
: 232709 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-10 13:58 UTC by aquaglia
Modified: 2013-10-31 09:50 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
One Unit Test class for which Run Focused Test is greyed out (9.05 KB, text/x-java-source)
2013-07-10 15:17 UTC, aquaglia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aquaglia 2013-07-10 13:58:25 UTC
Product Version: NetBeans IDE 7.4 Beta (Build 201307092200)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b17
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\quaglan\AppData\Roaming\NetBeans\7.4beta
Cache directory: C:\Users\quaglan\AppData\Local\NetBeans\Cache\7.4beta
Comment 1 aquaglia 2013-07-10 14:05:24 UTC
Same projects works fine in 7.3.1 and worked fine in first 7.4 beta
Comment 2 Marian Mirilovic 2013-07-10 14:20:20 UTC
I am sorry, but I have no idea what are you talking about, could you please write down exact steps to reproduce or/and provide screenshot ? Thanks in advance.
Comment 3 aquaglia 2013-07-10 14:27:37 UTC
Sure, I right-click inside a JUnit test and the "Run Focused Test" item is greyed out. The very same project and file work fine in previous versions.
Comment 4 Jiri Kovalsky 2013-07-10 14:50:37 UTC
What kind of project is that? Ant or Maven based? Can you attach a sample?
Comment 5 aquaglia 2013-07-10 15:04:24 UTC
Java/Maven project.
Comment 6 aquaglia 2013-07-10 15:14:24 UTC
It only happens for some of the test classes.
Comment 7 aquaglia 2013-07-10 15:17:22 UTC
Created attachment 136962 [details]
One Unit Test class for which Run Focused Test is greyed out
Comment 8 aquaglia 2013-07-10 15:19:28 UTC
I have switched back to 7.3.1
Comment 9 aquaglia 2013-07-10 15:29:33 UTC
I know that there have been changes of this functionality and that the previous messaging has been amended but in this release I do not see any message at all.
Comment 10 Jiri Kovalsky 2013-07-10 22:21:37 UTC
I think I have reproduced this problem. The "Run Focused Test Method" popup menu is disabled inside tested class even in NetBeans 7.3.1 but the truth is that in the test class itself it is enabled and executes the selected test while this does not work in NetBeans 7.4 Beta. Talking about Maven based project. In Ant based project it all works fine.

Theofanis, feel free to stop by my desk today if you cannot reproduce it.
Comment 11 aquaglia 2013-07-15 07:25:49 UTC
I have found some time to do some additional testing.

The issue is caused by the unit test class name being different from the test class.
The tested class is INSPIREResourceRepresentation
The test class is INSPIREResourceRepresentationTest10

If the test class is named INSPIREResourceRepresentationTest everything works fine.

Is this some additional requirement from JUnit 4?

Shall I change my code and put all test methods in a single class file?
That would be a problem for me.

I raise the priority of this issue since the upgrade to JUnit 4 was forced by other changes introduced with this same beta and this new issue forces me to code do changes.
Comment 12 Theofanis Oikonomou 2013-07-25 14:20:04 UTC
(In reply to comment #11)
> I have found some time to do some additional testing.
> 
> The issue is caused by the unit test class name being different from the test
> class.
> The tested class is INSPIREResourceRepresentation
> The test class is INSPIREResourceRepresentationTest10

This is the root for the problems you see in beta. Since bug 227358 there was a change in the way the "Run/Debug focused test method" menu items get enabled.

In order for the infrastructure to be able to navigate to/from test class and/or execute test class or test method the test class file name should end with "Test"

> 
> If the test class is named INSPIREResourceRepresentationTest everything works
> fine.
> 
> Is this some additional requirement from JUnit 4?

no it is not.

> 
> Shall I change my code and put all test methods in a single class file?

You can rename INSPIREResourceRepresentationTest10 to INSPIREResourceRepresentation10Test. Then the "Run/Debug focused test method" menu items will be enabled but you will not be able to navigate to the tested class, but you could not do that in previous release as well.

> That would be a problem for me.
> 
> I raise the priority of this issue since the upgrade to JUnit 4 was forced by
> other changes introduced with this same beta and this new issue forces me to
> code do changes.

Closing as wontfix as you manually created those test classes and there are error messages when you create the test class from the Tolls->Create Tests menu item to indicate that things will not work as expected if you modify the default name for the test class.
Comment 13 aquaglia 2013-07-26 08:14:30 UTC
The workaround works.
I can certainly accept to rename the test classes.
Many thanks.
Comment 14 Jiri Kovalsky 2013-07-26 08:53:48 UTC
OK, verifying then.
Comment 15 almson 2013-08-19 18:27:43 UTC
I don't like this at all.

I have been using files under Test Packages that end in *Tasks which are collections of pieces of code that do administrative tasks related to my application. I used "Run focused test" to great effect. Then I lost that capability with no explanation of why. Good thing I knew what I was missing and Google brought me to this bug, explanation of the problem, and workaround. What is a new user supposed to do? 

It is better to check if the file is indeed in the Test Packages, than to dictate how those files should be named, what they should contain, or to say that anything not created through the Netbeans wizard is a second-class citizen.

I love Netbeans and Java for obeying the principle of least surprise and being very flexible (unlike the inconsistent pile that is VS/C#), so please find a more elegant fix to bug 227358.
Comment 16 Theofanis Oikonomou 2013-08-21 10:27:39 UTC
(In reply to almson from comment #15)
> I love Netbeans and Java for obeying the principle of least surprise and
> being very flexible (unlike the inconsistent pile that is VS/C#), so please
> find a more elegant fix to bug 227358.

Please have a look in https://netbeans.org/bugzilla/show_bug.cgi?id=232709#c11
Comment 17 almson 2013-09-02 12:11:05 UTC
Thanks!

*** This bug has been marked as a duplicate of bug 232709 ***
Comment 18 aquaglia 2013-09-02 13:37:17 UTC
Shouldn't bug 232709 be marked as a duplicate of this one and not vice versa?
Comment 19 Theofanis Oikonomou 2013-09-02 14:19:25 UTC
(In reply to aquaglia from comment #18)
> Shouldn't bug 232709 be marked as a duplicate of this one and not vice versa?

you are correct since this one was filed earlier. Thanks

For the record this was fixed by http://hg.netbeans.org/core-main/rev/3a4b61b7a20a
Comment 20 Theofanis Oikonomou 2013-09-02 14:20:10 UTC
*** Bug 232709 has been marked as a duplicate of this bug. ***