aspose file tools*
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
Author

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\CalculatorFourTest.java:5: 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: 16305
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Consider Paul's rocket mass heater.
 
subject: Problem with JUnit integration in Eclipse