Bug 488566 - [JUnit][JUnit 5] Add support for JUnit 5
Summary: [JUnit][JUnit 5] Add support for JUnit 5
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement with 18 votes (vote)
Target Milestone: 4.7.1a   Edit
Assignee: Noopur Gupta CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 502563 507171 510496 510498 510569 511443 511630 511633 512114 514707 517063 517295 517993 518052 518163 518185 518239 518244 520923 521242 521243 521246 521464 521750 521841 521854 522119 522339 522732
Blocks:
  Show dependency tree
 
Reported: 2016-02-26 09:51 EST by Roland Tepp CLA
Modified: 2017-10-05 15:51 EDT (History)
27 users (show)

See Also:


Attachments
Installing Eclipse plug-ins into host (74.59 KB, image/png)
2017-02-14 09:07 EST, Noopur Gupta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Tepp CLA 2016-02-26 09:51:05 EST
JUnit team has released first alpha of new JUnit 5 testing framework.

JUnit 5 is complete rewrite of the popular5 testing framework and among other goals of the new version is better support for IDEs and other third party test runners.

They are currently gathering feedback from potential consumers of JUnit api, so I would thing that this is a very good time for Eclipse JDT team to take a hard look at JUnit 5 development and start working together with Junit team on better test runner api design.
Comment 1 Robin Textor CLA 2016-07-15 15:29:06 EDT
The first stable release of JUnit 5 is out...
IntelliJ already provides support for it...
Time to catch up!
Comment 2 Markus Keller CLA 2016-07-21 07:52:10 EDT
Noopur, please have a look at http://junit.org/junit5/ and see how we can integrate support for JUnit 5 in Eclipse.

JUnit 5 requires Java 8. Although the JUnit Vintage sub-project should allow running JUnit 3 and 4 tests, we still need to keep the native JUnit 3 and 4 runners to support running tests in environments where Java 8 is not available.

https://dev.eclipse.org/mhonarc/lists/jdt-ui-dev/msg01488.html mentioned a prototype for basic JUnit 5 support in Eclipse, but it doesn't look like it has been updated recently, so I guess it's probably easier to just start from scratch.
Comment 3 Markus Keller CLA 2016-08-04 08:58:43 EDT
http://search.maven.org/#search%7Cga%7C1%7Corg.junit and page 2 should yield links to download pre-built versions of JUnit 5 JARs and source JARs. These will eventually go into Orbit, but only after they have been officially released.

Use the newer org.junit.platform, org.junit.vintage, and org.junit.jupiter versions (M2), and not the 5.0.0-ALPHA stuff.

Implementation-wise, the new org.eclipse.jdt.junit5.runtime bundle that will be provided as part of this bug will depend on the orbitized JUnit 5 bundles. In non-OSGi contexts where the o.e.j.junit5.runtime JAR will just be put on the classpath, the OSGi dependencies in the MANIFEST.MF will not be processed anyway.
Comment 4 Noopur Gupta CLA 2016-11-04 06:22:05 EDT
Released the initial code to BETA_JUNIT5 branch of jdt.ui repo and added the new org.eclipse.jdt.junit5.runtime bundle with required JUnit 5 JARs to a new repo on GitHub.

Follow these steps to setup the code and try out the JUnit 5 support:

- Open a new workspace with Eclipse 4.7 M3 build and set API baseline as Eclipse 4.6.

- Clone the repo: https://github.com/noopur2507/eclipse-junit5.git and import the project: org.eclipse.jdt.junit5.runtime

- Copy the jars from the cloned folder eclipse-junit5\JUnit-5-JARs to your Eclipse's "dropins" folder.

- Clone the repo: git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git and checkout the BETA_JUNIT5 branch. Import the projects: org.eclipse.jdt.ui, org.eclipse.jdt.junit, org.eclipse.jdt.junit.core, org.eclipse.jdt.junit.runtime, org.eclipse.jdt.junit4.runtime

- Restart Eclipse. The workspace should not have any error now.

- Launch a runtime Eclipse application to try out the JUnit 5 support. You can add the JUnit 5 library container to a project via the Java Build Path settings or with the help of a quick fix on @Test / @TestFactory / @Testable.

It's a work in progress and known to have some missing functionality and issues, which are not yet listed on Bugzilla. So, please feel free to provide feedback and report issues.
Comment 5 Sam Brannen CLA 2016-11-05 12:19:45 EDT
First and foremost, thanks for the great work Noopur!!!

I tried it out and am really quite impressed. :)

The only issue I noticed is that the green/red success/failure bar in the JUnit view is displayed as green if the return type for a dynamic test method is invalid. The dynamic test and its enclosing class are in fact marked as as failures (i.e., red). Thus, the overall test run should also be marked as a failure. To reproduce this, just run the DynamicTestsDemo [0].

If you need me to create a new bug issue to track this, just let me know.

Cheers,

Sam


[0] https://github.com/junit-team/junit5/blob/ba94add9b2c522f867f17a693960fad6b72716ca/documentation/src/test/java/example/DynamicTestsDemo.java
Comment 6 Noopur Gupta CLA 2016-11-07 10:37:27 EST
(In reply to Sam Brannen from comment #5)

Thanks, Sam. I have created bug 507171 for the reported issue.
Comment 7 Aurelien Pupier CLA 2016-11-30 05:30:15 EST
Just a note to notify about the 5.0.0-M3 release http://junit.org/junit5/docs/current/user-guide/#release-notes-5.0.0-m3

there are several breaking changes mentioned, I have no idea if Eclipse is hit by one of them but will worth planning to test it.
Comment 8 Noopur Gupta CLA 2016-12-08 08:21:30 EST
I have updated the repositories mentioned in comment #4 to adapt to the 5.0.0-M3 release of JUnit 5.

Instead of Eclipse 4.7 M3 build, the 4.7 M4 build should be used now to try out the JUnit 5 support in Eclipse based on the steps in comment #4.
Comment 9 Dmytro Shyshchenko CLA 2017-02-14 08:03:14 EST
I am a newbie and I cannot run any single JUnit5 test following the steps described here :( I always get a NullPointerException. What do I do wrong? P.S. I use Windows. I see JUnit 5 test runner assigned to my project in the Eclipse.
P.S.S. Btw, is there a way to start an Eclipse with JUnit5 support not from another Eclipse, but like a separate Application? Like compiling and deploying org.eclipse.jdt.junit.runtime somewhere? Sorry if it is a stupid question...

!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localURL(JUnitLaunchConfigurationDelegate.java:502)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.entryString(JUnitLaunchConfigurationDelegate.java:484)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.addEntry(JUnitLaunchConfigurationDelegate.java:476)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:467)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getClasspath(JUnitLaunchConfigurationDelegate.java:444)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launch(JUnitLaunchConfigurationDelegate.java:161)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Comment 10 Noopur Gupta CLA 2017-02-14 09:07:35 EST
Created attachment 266815 [details]
Installing Eclipse plug-ins into host

(In reply to Dmytro Shyshchenko from comment #9)
> I am a newbie and I cannot run any single JUnit5 test following the steps
> described here :( I always get a NullPointerException. What do I do wrong?
> P.S. I use Windows. I see JUnit 5 test runner assigned to my project in the
> Eclipse.

Your stack trace shows that it is not able to find the "org.eclipse.jdt.junit5.runtime" bundle which is present in the GitHub repo: https://github.com/noopur2507/eclipse-junit5.git. See comment #4 - make sure that you have cloned and imported the "org.eclipse.jdt.junit5.runtime" project in your Eclipse workspace.

I would recommend to use the latest stable Eclipse I-Build (currently, I20170212-2000) which is available at http://download.eclipse.org/eclipse/downloads/index.html and follow the steps from comment #4.

> P.S.S. Btw, is there a way to start an Eclipse with JUnit5 support not from
> another Eclipse, but like a separate Application? Like compiling and
> deploying org.eclipse.jdt.junit.runtime somewhere? Sorry if it is a stupid
> question...

After this step from comment #4:
> - Restart Eclipse. The workspace should not have any error now.
you would have imported all the required projects in your Eclipse workspace with no errors and the JUnit jars would be present in your Eclipse's "dropins" folder. 

Now, you can go to File > Export... > Deployable plug-ins and fragments. Here, select all the imported plug-ins and choose "Install into host..." under "Destination". Click Finish. It will install these plug-ins into your Eclipse IDE. (See attached screenshot)

As a result, you now have an Eclipse IDE with JUnit 5 support in it. You can open a new workspace with it and try out the JUnit 5 support directly.
Comment 11 Dani Megert CLA 2017-02-14 10:35:16 EST
This feature will not be part of Oxygen (4.7) since the GA of JUnit 5 is now in 3Q 2017: https://github.com/junit-team/junit5/wiki/Roadmap
Comment 12 Sam Brannen CLA 2017-03-09 08:34:45 EST
FYI: The JUnit 5 team is reconsidering the road map for a GA release.

Thus, could you please inform us of the official cut-off date by which JUnit 5 GA would need to be released in order to have support included in Eclipse 4.7?

Thanks!

The JUnit Team
Comment 13 Noopur Gupta CLA 2017-03-09 09:42:02 EST
For Eclipse 4.7, milestone M7 (2017/05/12) is the feature freeze. So we will need a feature complete version of JUnit 5 for M7. It would be better to have a JUnit 5 preview before M7 so that we can adopt the changes and do an initial CQ review and Orbit contribution.

We could also target the potential Java 9 release on July 27. Then, we could ship the JUnit 5 support in the same way as Java 9 support. Eclipse Planning Council is yet to take a decision on how it will be shipped. 

We can also ship the JUnit 5 support with Oxygen.1 (4.7.1) in September 2017.

Or, based on the current GA plan of JUnit 5, the support can be included in Oxygen.2 (4.7.2) in December 2017.
Comment 14 Sam Brannen CLA 2017-03-09 12:22:12 EST
Hi Noopur,

Thanks for the super fast feedback.

Based on the dates you've listed, the JUnit 5 Team will tentatively aim to have a GA release available to be included in Oxygen.1.

Really looking forward to that!

Cheers,

Sam
Comment 15 Dani Megert CLA 2017-03-10 09:21:59 EST
(In reply to Sam Brannen from comment #14)
> Hi Noopur,
> 
> Thanks for the super fast feedback.
> 
> Based on the dates you've listed, the JUnit 5 Team will tentatively aim to
> have a GA release available to be included in Oxygen.1.

This looks like a good choice to me.
Comment 16 Noopur Gupta CLA 2017-03-16 09:17:14 EDT
The steps to setup beta JUnit 5 support in Eclipse have been added to https://wiki.eclipse.org/JDT_UI/JUnit_5.
Comment 17 Marc Philipp CLA 2017-08-03 07:24:34 EDT
What does the "BETA JUnit 5" target milestone mean? Will it make it into 4.7.1 if the JUnit team releases according to plan?
Comment 18 Noopur Gupta CLA 2017-08-03 11:19:05 EDT
(In reply to Marc Philipp from comment #17)
> What does the "BETA JUnit 5" target milestone mean? Will it make it into
> 4.7.1 if the JUnit team releases according to plan?

Eclipse Planning Council is currently deciding the schedule for upcoming Oxygen releases to include JUnit 5 and Java 9 support.

The current proposal is to first have a Marketplace support after JUnit 5 GA in August/September. Then, release Oxygen.1 on September 27 without Java 9 and JUnit 5 support. And later release Oxygen.1a on October 11 with Java 9 and JUnit 5 support.

Refer https://dev.eclipse.org/mhonarc/lists/eclipse.org-planning-council/msg02780.html for the discussion.
Comment 19 Marc Philipp CLA 2017-08-03 13:34:33 EDT
So it got pushed back? Because of Java 9 or JUnit 5? Is Oxygen.1a a real release or an "alpha" release?
Comment 20 Noopur Gupta CLA 2017-08-04 02:33:08 EDT
(In reply to Marc Philipp from comment #19)
> So it got pushed back? Because of Java 9 or JUnit 5? Is Oxygen.1a a real
> release or an "alpha" release?

Oxygen.1 was always scheduled for September 27. Oxygen.1a with Java 9 + JUnit 5 support is now scheduled for October 11 to allow Oxygen.1 to be a usual stable release. Oxygen.1a will be a real release on top of Oxygen.1 and will be included in updates to all users.

Marc, could you please comment on the scheduled date for JUnit 5 GA so that we can plan the Eclipse Marketplace support around the same time?
Comment 21 Marc Philipp CLA 2017-08-04 05:02:50 EDT
GA is scheduled for August 24, 2017 (see https://github.com/junit-team/junit5/milestone/10). Originally it was later, but we moved it from September to August to be in time for the Oxygen.1 release. If you now don't need it until a bit later, we might do an RC3 on that date and release GA in early September (if that's still in time for Oxygen.1a).

So, when do you need the GA release?
Comment 22 Noopur Gupta CLA 2017-08-04 05:13:33 EDT
Having RC3 around August 24 and GA in the first week of September will be good for Oxygen.1a.
Comment 23 Marc Philipp CLA 2017-08-04 13:00:16 EDT
New Plan:
RC3 on Aug 24
GA on Sep 6

Does that work for you?
Comment 24 Noopur Gupta CLA 2017-08-04 13:41:13 EDT
(In reply to Marc Philipp from comment #23)
> New Plan:
> RC3 on Aug 24
> GA on Sep 6
> 
> Does that work for you?

Yes, thanks!
Comment 25 Noopur Gupta CLA 2017-08-07 10:05:19 EDT
(In reply to Noopur Gupta from comment #16)
> The steps to setup beta JUnit 5 support in Eclipse have been added to
> https://wiki.eclipse.org/JDT_UI/JUnit_5.

We now have a U-build and update site available for JUnit 5 support in Eclipse. The wiki page has been updated with details.
Comment 26 Noopur Gupta CLA 2017-09-05 10:08:02 EDT
(In reply to Noopur Gupta from comment #25)
> (In reply to Noopur Gupta from comment #16)
> > The steps to setup beta JUnit 5 support in Eclipse have been added to
> > https://wiki.eclipse.org/JDT_UI/JUnit_5.
> 
> We now have a U-build and update site available for JUnit 5 support in
> Eclipse. The wiki page has been updated with details.

JUnit 5 support is now included in Eclipse Photon (4.8) builds also. You can try it out with the latest Integration build available here: http://download.eclipse.org/eclipse/downloads/index.html.

The wiki page (https://wiki.eclipse.org/JDT_UI/JUnit_5) has been updated.

Check out the Eclipse Marketplace entry for details on JUnit 5 support in Eclipse: https://marketplace.eclipse.org/content/junit-5-support-beta-oxygen.
Comment 27 Marc Philipp CLA 2017-09-05 12:49:37 EDT
Would pushing back the JUnit 5.0 GA release to this weekend still be acceptable?
Comment 28 Noopur Gupta CLA 2017-09-05 14:27:57 EDT
(In reply to Marc Philipp from comment #27)
> Would pushing back the JUnit 5.0 GA release to this weekend still be
> acceptable?

Yes, that would be fine.
Comment 29 Noopur Gupta CLA 2017-10-04 08:29:05 EDT
Marking this bug as resolved.

You can have a look at the noteworthy items here: https://www.eclipse.org/eclipse/news/4.7.1a/#junit-5-support.

Thanks to everyone who was involved!
Comment 30 Sam Brannen CLA 2017-10-05 15:51:48 EDT
Congratulations on a job well done!