I'm currently using the Eclipse Helios IDK and have the newest JRE (1.6) installed. I have added both the 4.8 and 4.9 versions of the junit jar to the build path. However, whenever I right click>new there is not an option to create a junit test case like you would expect. Even after going to other>java and every other directory within other I couldn't find the option to create a test case. Do I need to get a plugin in order to initialize these .jar files?
Thanks for any help in advance!
By default (and in my Helios, too) JUnit Test Case should be available even if no JUnit jar is in your classpath. Eclipse then asks to add the JUnit jar to the classpath.
Try removing the jars and start the "New.." wizard again.
Related
Im using Eclipse Juno. I imported a SVN (Subversion) project. I am trying to unit test the java classes on a module. I am using Java Perspective.
build path library has Junit4.
I have this Problems:
When im adding a new JUnit test case, the textbox from "class under test" has an error of "class under test doesnt exist in current project". But I just right clicked the java class I want to be tested and add new JUnit Test Case.So basically the error showing up doesnt make any sense. Because the class under test exist.
Theres no "run as JUnit Test" in the existing Java Test Class imported from SVN.
if I right clicked the test class > run as > run config only ***Theres no Junit Test
Eclipse Setup is Default except this settings:
in Window> Preferences > Java> Installed JRE > Jdk 1.7
in Window> Preferences > Maven > Installtion > Maven 3.0.4 (External)
Please Help me, consider me as a newbie in Unit Testing and in SVN Projects. I dont have any idea what to do.
Can anyone teach me how to create a Junit Test Case from a test class of a SVN Project.
Can You also Instruct the proper Eclipse Settings. (Files and Instructions)
Thanks in advance.
Add JUnit to your buildpath and it will solve some or both of your problems. I just tested this on Indigo though I couldn't recreate your first issue.
I've got Eclipse (Helios) installed along with the JUnit3, JUnit4 and Java Development Tools plug-ins for some Android development.
I've created some unit tests but the only way they run (without throwing a java.lang.ClassNotFoundException for org.junit.Test) is if I add an External JAR to the test project build path for junit.jar from the normal JUnit install I have.
Why isn't Eclipse able to reference the junit.jar from the JUnit4 plugin which I can see when I expand the library in Package Explorer? In fact I can remove the JUnit4 Library from the test project leaving just the External JAR and the tests run fine.
I tried adding the path to the plug-in folder to my CLASSPATH system environment variable as I had to setting up JUnit but this made no difference. The plugin path is created as a JUNIT_HOME Classpath Variable in Eclipse but this is labeled as deprecated.
Do I even need the JUnit3 and JUnit4 plugins as these must have come with the distro I used?
In any new project, the sure way I add the required Junit deps (with the exception of declaring them in maven) is through creating the test using the in-built Junit test shortcut.
Go to New > Junit Test Case. If the right deps are not on the project classpath, eclipse will pull them in automatically.
I just started maven in general and m2eclipse in specific.
What I have been doing before is follow:
1)Deploy my application to tomcat.
2) make any changes to the java or jsp files.
3) save and run the application again ( no restart is neccessary unless I changed a config file).
now, everytime I make a minor change to my maven project in eclipse I have to do a "pre-clean install" to compile and deploy the application again and then restart weblogic 10 to view the changes.
Is there anyway ( or maybe I m not doing something right) that I when I modify a class or jsp file, the code will get compiled and deployed when I save the file like I was doing before with the eclipse default project builder and tomcat?
Also, When I checkout the maven project from SVN, Eclipes shows bunch of compiling errors due to some missing classes, but when I build the project using m2eclipse everything builds successfull. Why is eclipse not recognizing the classes??
I have looked at the following answer but I was not able to figure out the problem.
How do I start Maven "compile" goal on save in Eclipse?
now, everytime I make a minor change to my maven project in eclipse I have to do a "pre-clean install" to compile and deploy the application again and then restart weblogic 10 to view the changes.
You shouldn't have to do that. Are you using the Oracle Enterprise Pack for Eclipse (OEPE) (available from the market place or from an update site) and the WTP?
Is there anyway ( or maybe I m not doing something right) that I when I modify a class or jsp file, the code will get compiled and deployed when I save the file like I was doing before with the eclipse default project builder and tomcat?
See above.
Also, When I checkout the maven project from SVN, Eclipes shows bunch of compiling errors due to some missing classes, but when I build the project using m2eclipse everything builds successful. Why is eclipse not recognizing the classes??
Try the following: right-click on the project then Maven > Update Project Configuration.
I would like to upgrade the JUnit version of my Eclipse Galileo (on windows) to JUnit 4.8.1 instead of the included JUnit 4.5. There does not appear to be a plugin update to use the new version or a way to change the location of the JUnit 4 jars. How can I update to the new version and/or use a JUnit jar not under the eclipse install directory?
For plain java projects
You could add the junit.jar you want to use as a file in your project, add it to the build path, and remove the eclipse defined junit library from the build path (assuming it was there).
For plugin projects
You can do as above or, create a new plugin from the junit 4.8 jar and add it to your test plugin's dependencies.
Note: Eclipse Galileo 3.5.2 (just released today), and Eclipse Helios 3.6M5 (to be released) have JUnit4.8 in them.
See this Planning Meeting Notes from last January, 27th.
Darn... As The OP Andrew comments, the latest Eclipse 3.5.2 still got a JUnit4.5.
As stevendick adds: it shouldn't make it in the 3.5 release cycle, but should probably make it in the last 3.6Mx releases.
I'm using Ganymede on Ubuntu Linux and I have junit-4.3.1.jar in my build path. I click File > New > Java > "JUnit 4 Test Case" when I create a new test, but when it's run, Eclipse appears to be using JUnit 3. I believe this is the case because it's ignoring my annotations.
When I remove all test* methods, JUnit complains "No tests found". If I do the same with another test I already created, JUnit runs fine and finds my test named createTask(). So, it appears to be using JUnit 3 at times, and JUnit 4 at others.
How do I force Eclipse Ganymede to use JUnit 4?
I figured out the answer via this link:
Spring is apparently incompatible with JUnit 4.3.1 when extending AbstractTransactionalSpringDataSourceTest (or whatever it is). So, I upgraded to JUnit 4.6 (b/c 4.5 has issues) and used the annotation-based configuration, and voila, all is well.
Thank you.
I have 2 suggestions that might help. First, in the Run/Debug configuration, Make sure the JUnit 4 test runner is selected. Next, if this is a plugin project, add the junit4 runtime to the project as a dependency (in the dependencies tab).