Fedora Linux Support Community & Resources Center
  #1  
Old 19th February 2010, 11:19 PM
akiross Offline
Registered User
 
Join Date: Feb 2010
Location: Italy
Age: 32
Posts: 73
linuxsafari
Thumbs up JUnit 4 with Eclipse-jdt [solved]

Hello,
I'm sorry, as I'm not sure if this is the right forum: this is a problem I'm having with software, it's on a x86_64 machine, but it's programming related (and I suspect it's a my problem not a fedora's problem as I can't find solutions)

I'm using Eclipse since a month or two, and only today I wanted to learn how to use JUnit. I tried following some tutorials, but eclipse complains.
Actually, it seems that Eclipse can't find JUnit4 (which is installed btw), as

Project > Properties > Java Build Path > Libraries tab
There is JUnit4, but editing it
JUnit library version: JUnit 4
Current Location: Not Found
Source Location: Not Found

But JUnit 3 have a valid
Current Location: junit.jar - /usr/lib64/eclipse/dropins/jdt/plugins

I tried adding by hand the system-installed junit4.jar file, but eclipse complains when running tests (a NullPointerException is thrown on launching).

I'm actually using JUnit3, which works, but seems quite limited...

What shall I do? How do I check that all the configuration is fine? Eclipse is so vast...

Thanks
~Aki

Last edited by akiross; 24th February 2010 at 02:25 PM.
Reply With Quote
  #2  
Old 21st February 2010, 09:37 AM
dmyersturnbull Offline
Registered User
 
Join Date: Sep 2008
Location: California
Posts: 235
linuxfedoramozilla
Hey, Aki.

This bug was fixed in version 3.5.1-22 of Fedora eclipse. Apparently, it was Fedora’s fault
Have you updated Eclipse? Try that.

If the error persists, a temporary workaround would be to add an Eclipse Library (in preferences→Java→Build Path→User Libraries) and specify the path to the JUnit4 in the Fedora repos (run: locate junit4).
Reply With Quote
  #3  
Old 21st February 2010, 10:00 AM
akiross Offline
Registered User
 
Join Date: Feb 2010
Location: Italy
Age: 32
Posts: 73
linuxsafari
I'm using eclipse-jdt
Version : 3.5.1
Release : 22.fc12

But the problem persists :\ I tried going into preferences→Java→Build Path→User Libraries, adding a library "junit4" and importing the /usr/share/java/junit4.jar
But I don't know if this is sufficient - or if I did it wrong - as eclipse still complains:
the import org.junit cannot be resolved

Shall I configure something else and tell somehow eclipse to use that library for junit testing?

Anyway thanks!
Reply With Quote
  #4  
Old 22nd February 2010, 02:05 AM
dmyersturnbull Offline
Registered User
 
Join Date: Sep 2008
Location: California
Posts: 235
linuxfedoramozilla
Hey, akiross.

After creating the User Library in the Preferences menu, you need to configure your project to use it. Right‐click your project in the Package Explorer and choose Build Path→Add Libraries→User Library. Did you already do this?
Build Path→Add Libraries→External Archives should also work.

If that doesn’t work…
Sometimes Eclipse does strange things with the .classpath file (in your project’s directory). You can try making a new Eclipse project, then copying over your project source and re‐adding the JUnit library.
Reply With Quote
  #5  
Old 22nd February 2010, 12:40 PM
akiross Offline
Registered User
 
Join Date: Feb 2010
Location: Italy
Age: 32
Posts: 73
linuxsafari
Thanks for these instructions, but still doesn't work:
the imports are OK, as the annotations are recognized and no errors on the import org.junit, but when i Run As > JUnit Test, it gives an error:

'Launching TestParser' has encountered a problem.
An internal error occurred during: "Launching TestParser"
Details>>
An internal error occurred during: "Launching TestParser"
java.lang.NullPointerException

This is not my code fault (I guess), as even an empty test case gives this error when launching.

Thanks again

EDIT: With "empty test case" i mean a code like:

Code:
import org.junit.Test;
public class TestSomething {
	@Test
	public void test() { }
}
EDIT2: Sorry, but I really can't find other infos apart that message... It doesn't give the backtrace in the Problems View :\

Last edited by akiross; 22nd February 2010 at 01:04 PM.
Reply With Quote
  #6  
Old 24th February 2010, 12:57 PM
akurtakov Offline
Registered User
 
Join Date: Jan 2010
Posts: 10
linuxfedorafirefox
Possible resolution

Can you try installing eclipse-pde and check whether the problem is still there?
Reply With Quote
  #7  
Old 24th February 2010, 02:24 PM
akiross Offline
Registered User
 
Join Date: Feb 2010
Location: Italy
Age: 32
Posts: 73
linuxsafari
It solves!
Thanks akurtakov!
Reply With Quote
  #8  
Old 17th March 2010, 09:44 PM
gregor2005 Offline
Registered User
 
Join Date: Oct 2007
Posts: 22
linuxfedorafirefox
Re: JUnit 4 with Eclipse-jdt

thx, also worked for me

gregor
Reply With Quote
Reply

Tags
eclipsejdt, junit

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse dnbwise Using Fedora 1 23rd December 2007 12:13 AM
Junit, PyDev, and Eclipse? cypher543 Using Fedora 3 28th December 2006 03:20 AM
Junit and Java 5 to work in FC4 T.V.Casualty Using Fedora 1 19th October 2005 11:25 PM
Eclipse Platform crashes! "org.eclipse.ui.ide.workbench" could not be found wangxiaohu Using Fedora 1 16th June 2005 11:12 AM


Current GMT-time: 20:02 (Wednesday, 20-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat