Reputation: 938
I just want to know if there is a tool or a function on right click to generate automatically a jUnit class when we've created a basic java class ?
Because I think I've already done this... But I can not remember how.
IDE: Eclispe Mars.
Thanks !
Upvotes: 2
Views: 17652
Reputation: 6808
Some Eclipse versions (I don't remember in which one I saw it) if you right click on the class name, it shows "Create JUnit test case for this class" in the context menu. But in some others it does not do that. You can a key short cut for it.
Head to Window --> Preferences --> General --> Keys and search for junit. Then you can easily add the shortcut you want to:
Upvotes: 3
Reputation: 2075
Just select a class and go for : New->JUnit test case
Eclipse will ask you to checkbox all methods you want to test, and give you a nice configuration wizard, import junit etc...
Upvotes: 10
Reputation: 1788
You can download any of plugin for this like MoreUnit or JUnitRunner. Eclipse itslf, has build it JUnit tool. You can follow below steps: 1. Select a java file. 2. Right click -> New... --> JUnit Test Case 3. Next-> Select method to test
Upvotes: 1