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 252959 - Running or debugging of individual JUnit tests sometimes does not work
Summary: Running or debugging of individual JUnit tests sometimes does not work
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 8.1
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Theofanis Oikonomou
: 269322 (view as bug list)
Depends on:
Reported: 2015-06-12 16:08 UTC by Jiri Kovalsky
Modified: 2017-07-18 08:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Project reproducing inability to run individual JUnit tests. (17.10 KB, application/zip)
2015-06-12 16:08 UTC, Jiri Kovalsky
cache TestSession at instance construction (1.31 KB, patch)
2016-12-16 15:53 UTC, skygo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Kovalsky 2015-06-12 16:08:26 UTC
Created attachment 154187 [details]
Project reproducing inability to run individual JUnit tests.

Product Version: NetBeans IDE Dev (Build 201506110001)
Java: 1.7.0_76; Java HotSpot(TM) 64-Bit Server VM 24.76-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_76-b13
System: Linux version 3.13.0-37-generic running on amd64; UTF-8; cs_CZ (nb)
User directory: /home/cesilko/.netbeans/dev
Cache directory: /home/cesilko/.cache/netbeans/dev

Under some circumstances users can neither run nor debug individual JUnit tests due to an invalid format of arguments. Maybe it's a consequence of JUnit library upgrade to version 1.12. See this error output:

/home/cesilko/.cache/netbeans/dev/executor-snippets/junit.xml:140: The following error occurred while executing this line:
/home/cesilko/.cache/netbeans/dev/executor-snippets/junit.xml:78: Invalid specification of test methods: "teststorun.CalculatorTest.testAdd"; expected: comma-separated list of valid Java identifiers
BUILD FAILED (total time: 0 seconds)

Steps to reproduce:
1. Launch NetBeans IDE and open attached CannotRunIndividualTest project.
2. Right click "Source Packages > teststorun" node and invoke "Tools > Create/Update Tests" from popup menu.
3. In "Create Tests" dialog just push "OK" button.
4. Right click "CannotRunIndividualTest" project and invoke "Test" from its popup menu.
5. In "Test Results" output window right click "No test passed... > teststorun.CalculatorTest Failed > teststorun.CalculatorTest.testAdd Failed: ..." node and invoke "Run Again" from its popup menu.

Expected: The testAdd test is run and you see that it failed again in the Test Results output window and no other test results.
Actual: The testAdd test is not run due to the aforementioned error.
Comment 1 Theofanis Oikonomou 2015-09-17 14:04:41 UTC
It happens randomly. I cannot reproduce all the time. For example if I test the project or right click inside the editor and test just focused method or class and then invoke the "Run again" action from inside TRW it works. If I am debugging it never happens.
Comment 2 Jiri Kovalsky 2015-09-18 14:47:39 UTC
I don't agree. For me this is 100% reproducible. I can show you Fanis next time I am in the office.

Do you mean that if you exactly follow the reproduction steps you sometimes get the testAdd test run again?
Comment 3 Jiri Kovalsky 2016-12-14 22:52:22 UTC
*** Bug 269322 has been marked as a duplicate of this bug. ***
Comment 4 skygo 2016-12-16 15:53:53 UTC
Created attachment 163265 [details]
cache TestSession at instance construction

 I investigate a bit with lots of system.err (sorry) on the call stack.

 It seems that getName() method ask for TestSuite with no garantee to get the related TestSuite if called too late after another Testsuite is added to the session.

 The patch is an example for a fix, but I'm not sure this is the right way to do.

Comment 5 Radek_Vymetal 2017-07-18 08:14:10 UTC
This bug is reproducible also on newer version

Product Version: NetBeans IDE 8.2 (Build 201705191307)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_141; Java HotSpot(TM) Client VM 25.141-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_141-b15
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
User directory: C:\Users\rvymetal\AppData\Roaming\NetBeans\8.2
Cache directory: C:\Users\rvymetal\AppData\Local\NetBeans\Cache\8.2