Originally posted by rathi ji:
I assume, everybody here is familiar with junit. We write test method for each public method for all the classes that are in project, except getter-setter methods.
If XDoclet doesn't serve your needs, this would be a reasonably simple program to implement yourself. Iterate all classes on the classpath, ignoring test classes; use the reflection API to derive the methods (see the Class method getDeclaredMethods); iterate each method, ignoring methods starting with "get", and check each method to see if it's public (use getModifiers).
There are of course products that do a much more comprehensive job for you, that attempt to create the entire set of unit tests. You might take a look at Agitar or Parasoft.
Note that a one-to-one relationship between a test method and a production method isn't what you always want. Often you may require multiple test cases to completely exercise a given production method.
Another alternative is to consider the use of test-driven development, in which case the process is reversed--you write the test, then have your
IDE (Eclipse, IDEA both do this) generate the production stub code.
-Jeff-