tags:

views:

396

answers:

3

Is there a simple way of creating stubs for Junit4 tests in Eclipse (Galileo)?

A: 

If you want to create a stub implementation of an interface, then

  1. Create your stub class
  2. write implements MyInterface
  3. click on the red icon on the left (or press CTRL+1) and choose "add unimplemented methods"

A more generic approach is, when you create your class, and add extends / implements, go to Source > Override/Implement methods. The downside is you will have to clear some super calls.

Bozho
+6  A: 

Right click on a class/file in the package explorer, then new-> JUnit Test Case. Then a dialog opens and if you click the next button it allows you to check which methods to automatically create the stubs for.

Michael Patterson
+1 thanks - that was what I was after.
peter.murray.rust
+1  A: 

You might also look into Fast Code Eclipse Plugin. Once you configure you can generate junit/testng test by selecting the class or any method. Also gives you way to navigate from a method to all the tests. The popup dialog doesn't appear every time.

fastcodejava