Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 177676

Summary: [JUnit] Problems with JUnits with multiple versions of same bundle
Product: [Eclipse Project] JDT Reporter: DJ Houghton <dj.houghton>
Component: UIAssignee: Martin Aeschlimann <martinae>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: benno.baumgartner, bpasero, markus.kell.r, mlists
Version: 3.3Flags: markus.kell.r: review+
martinae: review+
Target Milestone: 3.3 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 153429, 179449, 186369    
Attachments:
Description Flags
3 junit plug-ins
none
patch
none
revert
none
updated patch none

Description DJ Houghton CLA 2007-03-15 18:24:11 EDT
Created from as part of investigation of bug 165356.

In the Platform we would like to ship:
- org.junit (3.8.2)
- org.junit (4.1.0.1)
- org.junit4 (wrapper)

The wrapper bundle will do a Require-Bundle on org.junit 4.1.0.1 and then re-export it.

Currently I am running into problems running the Junit tests when I have this setup. I will attach the bundles to this report.

I don't have an extensive list of the problems yet, but my first one is:

- create plug-in project aaa with a class called aaa.AAA and a static foo() method
- create plug-in project aaa.tests which has a test case which calls aaa.AAA#foo

When you create a launch config (plug-in test) for junit 4 it works ok but when you switch it to be junit 3 you get an error that no tests are found. 

I will annotate this report with more problems (and hopefully solutions) as I come across them.
Comment 1 DJ Houghton CLA 2007-03-15 18:26:55 EDT
Created attachment 61024 [details]
3 junit plug-ins

Delete the Junit plug-ins from an Eclipse SDK and then use the ones in this zip.

(I used i20070313)
Comment 2 DJ Houghton CLA 2007-03-20 11:09:44 EDT
Part of these errors are from something that I had in the setup of my workspace. I will investigate further next week.
Comment 3 Martin Aeschlimann CLA 2007-05-10 10:41:30 EDT
Created attachment 66684 [details]
patch

This patch fixes the JUnit classpath container to not be confused when there is a 'org.junit' plug-in around that has a >=4.0 version ('org.junit[4.3]') (It will still use (org.junit4))
From what I tested it is now no problem to have org.junit[4.3] around; the runner works with normal JUnit tests and JUnit Plug-in test.

However, clients plug-ins must not _use_ org.junit[4.3], as our remote junit runner has a plug-in dependency on org.junit4. I they do, we end up with two incompatible instances of the same classes.
I don't know how to solve that. Somehow we would like to avoid the hardcoded reference of org.junit4 from junit4.runtime, but a.) its in the manifest which we can't modify, b.) we would have to know what the client used for his tests.
We could change from plug-in dependencies to imported packages. But then we  still run into problems when two plug-in offer the same packages.

An other important discussion point is: the release of the new org.junit[4.3] will 'break' all test plug-ins that use org.junit but never bothered to add version constraints. Unfortunately, JUnit 4 is not 100% backward compatible with JUnit 3.
Comment 4 Martin Aeschlimann CLA 2007-05-10 10:49:31 EDT
Maybe org.junit4 could depend on org.junit[4.3] and reexport all its content. Maybe this solves the problem of having two instances of the same classes around.

Comment 5 Markus Keller CLA 2007-05-11 08:51:24 EDT
Released patch with a few tweaks, reviewed by Martin.
Comment 6 Benno Baumgartner CLA 2007-05-11 14:50:54 EDT
Sorry, have to revert, this leads to test failures in JUnit4TestFinderTests. Will attach a patch of what I've released.
Comment 7 Benno Baumgartner CLA 2007-05-11 14:54:08 EDT
Created attachment 66925 [details]
revert
Comment 8 Martin Aeschlimann CLA 2007-05-14 05:46:26 EDT
Created attachment 67026 [details]
updated patch
Comment 9 Martin Aeschlimann CLA 2007-05-14 06:27:38 EDT
Benno, can you review?
I tested the patch on the build machine.
Comment 10 Benno Baumgartner CLA 2007-05-14 09:56:59 EDT
Patch is good
Comment 11 Martin Aeschlimann CLA 2007-05-14 10:18:17 EDT
patch released > 20070514
Comment 12 Markus Keller CLA 2007-05-29 08:00:02 EDT
Verified in I20070527-0010