Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 153807 - [JUnit] java.lang.Exception: Unexpected TestElement type for testId '66': null
Summary: [JUnit] java.lang.Exception: Unexpected TestElement type for testId '66': null
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-14 14:39 EDT by Irina G. CLA
Modified: 2008-04-15 08:54 EDT (History)
1 user (show)

See Also:


Attachments
Sample test suite (2.73 KB, text/java)
2006-08-15 08:59 EDT, Irina G. CLA
no flags Details
Self-contained example (6.34 KB, application/x-zip-compressed)
2006-08-21 05:08 EDT, Markus Keller CLA
no flags Details
Patch (5.09 KB, patch)
2006-09-18 10:35 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Irina G. CLA 2006-08-14 14:39:46 EDT
I am getting the following error when running a JUnit test suite in Eclipse 3.2:

java.lang.Exception: Unexpected TestElement type for testId '66': null
	at org.eclipse.jdt.internal.junit.model.TestRunSession$TestSessionNotifier.logUnexpectedTest(TestRunSession.java:493)
	at org.eclipse.jdt.internal.junit.model.TestRunSession$TestSessionNotifier.testEnded(TestRunSession.java:397)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$4.run(RemoteTestRunnerClient.java:484)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.notifyTestEnded(RemoteTestRunnerClient.java:481)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.access$7(RemoteTestRunnerClient.java:476)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$DefaultProcessingState.readMessage(RemoteTestRunnerClient.java:90)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.receiveMessage(RemoteTestRunnerClient.java:342)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.access$26(RemoteTestRunnerClient.java:341)
	at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$ServerConnection.run
(RemoteTestRunnerClient.java:267)

I am using the latest version of eclipse and junit 3.8.1

I noticed that a bug has already been loogged for this issue (https://bugs.eclipse.org/bugs/show_bug.cgi?id=129725), but I am getting this error with the latest version of elipse. 

Any suggestions?
Comment 1 Markus Keller CLA 2006-08-15 07:08:53 EDT
I looked at the code again, and I really don't see how this could happen in 3.2.

Could you please verify that you're really running on build M20060629-1905?
Can you reproduce when you run the suite again?
Could you attach the test suite or strip it down to a sufficient example to reproduce?
Or could it be that you have an old version of org.eclipse.jdt.junit.runtime in your workspace?
Comment 2 Irina G. CLA 2006-08-15 08:59:20 EDT
Created attachment 47904 [details]
Sample test suite
Comment 3 Irina G. CLA 2006-08-15 09:04:28 EDT
I am using the latest eclipse build:
eclipse.buildId=M20060629-1905
java.version=1.5.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.jdt.junit 4 4 2006-08-14 16:36:48.441
!MESSAGE Error
!STACK 0
java.lang.Exception: Unexpected TestElement type for testId '77073': null
	at org.eclipse.jdt.internal.junit.model.TestRunSession$TestSessionNotifier.logUnexpectedTest(TestRunSession.java:493)


I do not see any org.eclipse.jdt.junit.runtime in my workspace. I have org.eclipse.jdt.junit only in the .metadata folder. 

I attached the sample test suite. 

In the classpath for my project, I am using junit 3.8.1, and this test suite was working fine on eclipse 3.1. The problem is only happening since I upgraded to eclipse 3.2 
Comment 4 Markus Keller CLA 2006-08-21 05:08:46 EDT
Created attachment 48264 [details]
Self-contained example

The problem is the unusual way of collecting tests. The example does not create the usual tree of TestSuites and TestCases, but creates a suite in the run(TestResult) method. This makes it impossible for the Eclipse JUnit implementation to find the test tree.

Need to see what we can do to support this case (e.g. just list all "unknown" failed test elements under the root node), or whether this setup has to be declared unsupported. Note that the example as given violates at least the contract of TestCase#countTestCases(). In 3.1, only the failures tab worked - the model tab stayed empty.
Comment 5 Markus Keller CLA 2006-09-18 10:35:13 EDT
Created attachment 50380 [details]
Patch

I've released the attached workaround for the upcoming 3.3 M2.
Comment 6 Markus Keller CLA 2007-05-11 19:02:15 EDT
Problem has been fixed for 3.3.
Keeping this bug open to add a regression test in 3.4
Comment 7 Mike Wilson CLA 2008-04-12 14:57:52 EDT
Has the regression test been added?

Lowering the priority since all that's left is to add the test.

Comment 8 Markus Keller CLA 2008-04-15 08:54:43 EDT
(In reply to comment #7)
> Has the regression test been added?

Yes, today ;-). See TestRunListenerTest#testTreeUnrootedEnded().