views:

243

answers:

4

Any tool for automatically generating unit tests for Java code?

UPDATE: Primary intended use is to quickly generate unit tests for legacy code that is going to be refactored. No need to automatically keep the tests in sync with the code after automatic generation.


Almost same question was asked here, but the answer was for .NET instead of Java (Pex was the accepted answer):

http://stackoverflow.com/questions/689087/automatic-generation-of-unit-test-cases-for-net-and-java

+2  A: 

I think Agitar had a tool like this called AgitarOne. I think you can still get it but make sure the company is still there.

Dror Helper
+1  A: 

CodePro Analytix has a JUnit test generation module that sounds like it will do what you want. Here is the documentation on how it works.

There is also CoView. These guys have a very reasonably priced product, at only $9.99 per user per year.

A third option would be to investigate AgitarOne Automated JUnit Generation.

All three products have a try before you buy option, so you could use them to compare the generated code against a small subset of your application.

Paul Wagland
+1  A: 

NetBeans does it automatically from Java source files (I guess the other IDEs too).

Maybe you could take a look into the junit plugin (link is currently down :-()?

Karussell
+1  A: 

Re: AgitarOne.

AgitarOne is still here and we would be happy to show you our JUnit Generator. Call us at 401-572-3150 or visit our web site. Thank you Dror for mentioning us.

Jon