Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How do I create a JUnit5 Test Suite in Eclipse?(Problems creating JUnit5 Test Suite.)
How do I create a JUnit5 Test Suite in Eclipse? [message #1796712] Thu, 18 October 2018 01:22 Go to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
I'm trying to learn JUnit 5 and how to create test cases and suites in Eclipse after a long absence from Java. I've gotten the hang of creating test cases with JUnit5 but I'm struggling to create the JUnit 5 test suites in Eclipse. It looks simple enough in the documentation but Eclipse is not co-operating.

I'm running Eclipse Oxygen.3a Release(4.7.3a), Build id: 20180405-1200 on Windows 10 and when I click on Help/Update, it tells me there are no updates available. I've been away from Eclipse for a few years too so I've forgotten: does this mean I am fully up-to-date or only that I have the latest update for Oxygen.3a but that it has been superseded by a newer version that I have to install to get all the latest bells and whistles?

The reason I ask is that Eclipse behaves as if JUnit 5 is only partially installed. I've created JUnit 5 test cases but when I try to create a JUnit 5 Test Suite, it only lets me choose between JUnit 3 and 4 - MOST of the time. But last night, I was struggling with it and it actually let me create a JUnit 5 test suite *and* run it successfully. I don't remember exactly how I did it though and every time I try to create a test suite successfully now, I don't get an option for JUnit 5.

I've tried the following:
- looked for YouTube videos on creating JUnit 5 Test Suites but videos were either JUnit 4 or earlier or they only covered creating test cases but not test suites
- looked for documentation online but couldn't find something that showed how to create test suites in Eclipse
- looked in the Eclipse documentation and found info about building test cases but not test suites.

I did find information about how to create Test Suites manually (http://howtodoinjava.com/junit5/junit5-test-suites-examples/) and have imitated that but one of two things happen:
- I get compile errors when I try to run the suite OR
- the suite runs but elapsed time is 0:00 and no tests are listed, which obviously means nothing happened

Here is my AllTests.java:
@RunWith(Suites.class)
@SelectPackages("com.domain.my")
@SuiteClasses({})
public class AllTests {

}

(I'm using Suites.class in the RunWith annotation because I get an error message when I use JUnitPlatform.class, which is what the documentation uses.)

I've structured my project slightly differently than the way recommended in the documentation; I found a good, short video on making test cases and followed his recommendation since he had lots of experience with JUnit 5. I have a regular Java project called Common with a standard src folder containing a package named com.domain.my; beneath it are the classes I want to test. Also directly under the project and therefore parallel to the src folder, I have a source folder called UnitTest. It contains a package called com.domain.my and that package contains my test cases, all of which work fine, and my test suite, AllTests, which is my current problem.

I would be happy to provide more information if you tell me what would help you help me :-)
Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1796713 is a reply to message #1796712] Thu, 18 October 2018 05:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Oxygen is quite old now and the built-in update sites for such an installation will only update to the latest Oxygen release, not to the Photon release nor to the 2018-09 release. It would seem better to visit https://www.eclipse.org/downloads/ and just create a new installation. The 2018-09 release definitely includes the JUnit 5 option in my installation...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1796880 is a reply to message #1796713] Sat, 20 October 2018 16:32 Go to previous messageGo to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Based on what you've said about the Oxygen update process, Ed, you've convinced me to upgrade to the newest stable release. Thanks!

UPDATE:
Well, that was disappointing. I installed the 2018-2019 Eclipse release without difficulty. However, I *still* can't create a JUnit5 Test Suite!

Initially, I just used the same workspace and let Eclipse convert it to the new format. Then I tried creating a test suite for the existing test cases I had. No dice: the only options I had were JUnit3 and JUnit4 test suites.

Then I tried creating an entirely new workspace for the new Eclipse install, then created a trivial class and a trivial test case for it. When I tried to create a new test suite for this code, I was *still* limited to creating only JUnit3 and JUnit4 test cases.

There must be a trick I haven't stumbled on yet. Can someone kindly point me to instructions or a video demonstrating how to make a JUnit5 test SUITE in a recent version of Eclipse?

Failing that, even an example of a basic JUnit5 test suite that has been manually written would be fine; then I'll just imitate that.

Your assistance would be greatly appreciated.

[Updated on: Sun, 21 October 2018 01:47]

Report message to a moderator

Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1796906 is a reply to message #1796880] Mon, 22 October 2018 07:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Doesn't the wizard look like this?
index.php/fa/34126/0/
I assume that Jupiter == 5


Ed Merks
Professional Support: https://www.macromodeling.com/

[Updated on: Mon, 22 October 2018 07:33]

Report message to a moderator

Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1796926 is a reply to message #1796906] Mon, 22 October 2018 12:54 Go to previous messageGo to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Yes, that's what I get for a test case but the wizard I see when I try to create a test SUITE only has options for JUnit 3 and JUnit 4.
Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1796934 is a reply to message #1796926] Mon, 22 October 2018 14:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
It looks like maybe this was overlooked:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=511183


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How do I create a JUnit5 Test Suite in Eclipse? [message #1797072 is a reply to message #1796934] Wed, 24 October 2018 19:12 Go to previous message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Thanks for finding that, Ed!

I didn't want to believe the Test Suite capability had been omitted - I had no reason to think so - so I thought I was just invoking it incorrectly and hoped to learn the "trick"....

From the wording in Bugzilla, it sounds like we shouldn't hold our breaths on Test Suites working with JUnit 5 any time soon.

That's not a big problem; I'll just execute the tests individually as needed for now. The main thing is that the JUnit 5 tests work fine and can be executed. Test Suites would have been nice but I can live without them.

Thanks again!

Previous Topic:Java Preferences - accessing system node in Windows
Next Topic:Widget disposed when using DeleteResourceAction
Goto Forum:
  


Current Time: Thu Apr 25 12:07:53 GMT 2024

Powered by FUDForum. Page generated in 0.03845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top