• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JUnit integration in Eclipse

 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic