Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346786 - [JUnit] sometimes the JUnit view gets stuck on the last test
Summary: [JUnit] sometimes the JUnit view gets stuck on the last test
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-21 11:05 EDT by John CLA
Modified: 2019-06-20 12:09 EDT (History)
5 users (show)

See Also:


Attachments
this is how it looks when it never returns (same as when it runs, I know) (13.82 KB, image/png)
2011-05-21 11:06 EDT, John CLA
no flags Details
the thread dump when it's stuck like that, if it helps (29.95 KB, text/plain)
2011-05-21 11:07 EDT, John CLA
no flags Details
another thread dump when it happened again (20.37 KB, text/plain)
2011-05-23 06:41 EDT, John CLA
no flags Details
this is how JUnit view looks when it's stuck (19.24 KB, image/png)
2011-05-23 06:53 EDT, John CLA
no flags Details
another thread dump when stuck at the last test without returning (26.81 KB, text/plain)
2011-05-26 12:58 EDT, John CLA
no flags Details
same TD as prev one, except this was dumped 19 mins later (26.29 KB, text/plain)
2011-05-26 13:15 EDT, John CLA
no flags Details
this is the TD after I pressed the stop button (1 hour and 1 min later) (26.29 KB, text/plain)
2011-05-26 13:57 EDT, John CLA
no flags Details
this is a TD after I reran the tests and the last test was modified to sleep 10 sec (30.69 KB, text/plain)
2011-05-26 13:58 EDT, John CLA
no flags Details
this is the TD right after the above one, it's after all tests ended successfully (22.49 KB, text/plain)
2011-05-26 14:04 EDT, John CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John CLA 2011-05-21 11:05:23 EDT
Build Identifier: I20110518-2200

in this view: Window->Show View, Java->JUnit
that is, when running the tests, 
sometimes the view gets stuck on the last test as if the test is blocking (but I have reason to believe it doesn't esp. since a (stop&)rerun will not block again).

So basically it will never return and I cannot see which tests failed and which not, because this only gets shown when all tests are done. The only thing to do is to press the red stop button, then rerun all tests (which will not block again this time)

It's tough to catch this, so I'll include the thread dump from the time when it did get stuck (luckily I was running the eclipse the right way for thread dump and dumped it with visualvm 1.3.2)

Reproducible: Sometimes

Steps to Reproduce:
(this "bug" is not restricted to e4, I've ran into this before on previous eclipses ie. 3.6-3.7)

I don't know how to reproduce it, but last time it happened when previous junit run had errors and pressing the Rerun Test button (the green one with a white play and yellow shortcut arrow on bottom right) caused it to not return (as seen in picture) although the test was done.
Comment 1 John CLA 2011-05-21 11:06:06 EDT
Created attachment 196267 [details]
this is how it looks when it never returns (same as when it runs, I know)
Comment 2 John CLA 2011-05-21 11:07:01 EDT
Created attachment 196268 [details]
the thread dump when it's stuck like that, if it helps
Comment 3 John CLA 2011-05-23 06:41:52 EDT
Created attachment 196314 [details]
another thread dump when it happened again

it's stuck at the last test, ie. it forgot to finish :) but all tests indeed finished, ie. it's not stuck in the test
Comment 4 John CLA 2011-05-23 06:53:47 EDT
Created attachment 196317 [details]
this is how JUnit view looks when it's stuck

this is the screenie from the previous (again) thread dump
Comment 5 Markus Keller CLA 2011-05-25 06:19:48 EDT
The thread hanging at org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart$JUnitIsRunningJob.run(TestRunnerViewPart.java:841)
indicates that the test run didn't terminate properly. It's hard to tell what's going on without a reproducible test case.

Is there anything special about these last tests or the test suite? E.g. do they use special test runners, or run tests in parallel like ActiveTestSuite, ...?
Are these JUnit 3 or JUnit 4 tests?
Comment 6 John CLA 2011-05-25 10:36:55 EDT
they are JUnit 4 tests
they don't run anything in parallel, I'd say they are pretty normal tests although the ones in this case do use some database which had locks (but I strongly doubt any deadlocks happened which caused hang)
The tests as the code they run for are designed to run only in 1 thread (well unless BerkeleyDB JE aka java edition doesn't run its own threads or something)

using junit-4.9b2.jar but these hangs have happened to me before in previous eclipses such as galileo even and when I used standard junit library, not hand-added one.

thing is I can't really reproduce them, the tests run fine , they only sometimes hang and after I stop the hang and rerun they don't hang again (even without modifying anything in them)

all tests use @Before and @After and @Test annotations only, ie. no @AfterClass (or what's it called, though if I do add that then I would most likely see that finish before the hang happens, sort of indicating that tests did finish - did this in one case months before and I remember the hang happening after the @AfterClass of the main runall tests suite)

tests are also (sometimes) ran via the main suite like this one:

@RunWith( Suite.class )
@Suite.SuiteClasses(
		value = {
			A.class, B.class, C.class, D.class, E.class
		} )
public class AllTestsGo {
}

but the A,B,C etc. classes (simplified here) are simple @Test and @Before and @After (sometimes) junit tests

Even if I find a testcase of tests that do hang , they will only hang that time, and most I could do is thread dump? trying to make them hang again may take about 1 day of normal development (as I do it anyway)
Comment 7 Markus Keller CLA 2011-05-25 11:44:42 EDT
Thanks for the info. So, the approach to fix the problem will be to dive into the code listens for test run session termination and that updates the view, so as to make sure it's properly synchronized.
Comment 8 John CLA 2011-05-26 12:58:54 EDT
Created attachment 196678 [details]
another thread dump when stuck at the last test without returning

I wonder if there's more I can "dump" or something to do to get more info and help with this
Comment 9 John CLA 2011-05-26 13:15:09 EDT
Created attachment 196683 [details]
same TD as prev one, except this was dumped 19 mins later

I didn't stop or do anything to the stuck junit test since the previous dump,
I was only checking the prev dump contents in visualvm while time was elapsing
Comment 10 John CLA 2011-05-26 13:57:13 EDT
Created attachment 196690 [details]
this is the TD after I pressed the stop button (1 hour and 1 min later)

the only thing I did (other than just wait for an hour) was I clicked the red stop button in junit view and then proceeded to thread dump
Comment 11 John CLA 2011-05-26 13:58:34 EDT
Created attachment 196691 [details]
this is a TD after I reran the tests and the last test was modified to sleep 10 sec

I took the TD while it was sleeping, then after it slept the test runs ended normally
Comment 12 John CLA 2011-05-26 14:04:00 EDT
Created attachment 196693 [details]
this is the TD right after the above one, it's after all tests ended successfully

that is, after those 10 seconds elapsed(and tests finished) I did a thread dump.
there were no errors in in the tests in all 4 previous thread dumps. All 5 of the last dumps(that means: includes this one) are connected, they are of the same eclipse session and as specified in their description.
Comment 13 Markus Keller CLA 2011-05-27 10:11:59 EDT
I don't think we'll get any more information out of stack dumps. This is a timing issue that causes a bad internal state in the updating code, so the bad information could only be found in a memory dump.

I currently don't have time to debug this, but the way I would approach it is by walking backwards from the code that updates the UI and see where the update is triggered. Then I would set some breakpoints to delay the updating and see if I can reliably reproduce the problem then.
Comment 14 Attila Kocsis CLA 2012-02-06 18:48:59 EST
Hi,

I can confirm the existence of this issue. I found that after the last test case was finished, the status bar does not get refreshed, but it stated that all the tests are done. (Runs: 2/2)

org.eclipse.jdt.junit - 3.7.0.v20110505-0800
org.eclipse.jdt.junit.core - 3.7.0.v20110518-0800

Thanks,
Attila
Comment 15 Stephane Arguin CLA 2014-09-16 11:13:47 EDT
Just to indicate that this problem is also in the latest Eclipse build (Luna). If it can help, my tests are parameterized (@RunWith(Parameterized.class))
Comment 16 Eclipse Genie CLA 2019-06-20 12:09:36 EDT
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.

If you have further information on the current state of the bug, please add it. 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.