File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Problem with JUnit integration in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Problem with JUnit integration in Eclipse" Watch "Problem with JUnit integration in Eclipse" New topic

Problem with JUnit integration in Eclipse

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
I created a project that uses Ant to compile a small application and its JUnit tests, runs the tests and creates a mail to send the test results. Everything works fine, but after I exported this project to a new workspace and can't make it to work with Ant from within Eclipse (it works fine when started from the command line). The error is:

[javac] D:\Workspaces Maik\Kolloquium\Ant Integration\tst\paketeins\ package junit.framework does not exist
[javac] import junit.framework.TestCase;

followed by unresolved symbol errors for each and every test case. The JUnit tests are JUnit 3 tests, by the way.

Somehow Eclipse can't find JUnit, but the workspace's classpath points at Eclipse JUnit plugin. As far as I can see, all settings are the same for both workspaces (but somehow there must be a mistake). Any ideas how to fix it?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Actually, if I understand, it's ANT that can't find Junit when run inside of Eclipse. Which is a common nuisance.

When you run Ant in Eclipse, start Ant with the setup dialog - e.g. right-click on the build.xml file in the Navigator, select "Run As/Ant Build...". Go to the CLASSPATH tab on that dialog and add the junit.jar to it. That sets up Ant's external classpath. The internal classpath isn't sufficient for Ant+JUnit or you could just add something to your build.xml file.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Problem with JUnit integration in Eclipse
It's not a secret anymore!