2

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 !

2
  • possible duplicate of stackoverflow.com/questions/10794008/create-junit-automatically Commented Sep 24, 2015 at 14:51
  • I do not want have all the tests written, but just the prototypes of the methods, I ll fill them myself. I think it's possible... Maybe I'm dreaming... Donno... Commented Sep 24, 2015 at 14:53

3 Answers 3

10

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...

Sign up to request clarification or add additional context in comments.

Comments

3

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:

enter image description here

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.