6

We have thousands of classes without any true unit test coverage. As special project we aim to add reasonable coverage to all. One option is to create tests from sourced code and use GenerateTestCases plugin with IJ.

I am exploring other options to create tests massively..

Is it possible to create tests (okay, just test-templates) from class files? TestGen4J does this, but the project seems to be inactive. Is there any tool that could help in creating the tests for thousands of classes.

Once such tests are generated, I hope we have more momentum to add more unit tests for existing classes.

Jayan
  • 18,003
  • 15
  • 89
  • 143
  • Do you actually want to generate tests? Such tests add almost no value since they wont have any real assertions. – Pavan Jan 02 '12 at 16:56
  • I did large legacy projects too, and concur with @PavanSudarshan. You probably want some more directed, sensible tests. FindBugs (http://findbugs.sourceforge.net/) is really much more helpfull. – Joop Eggen Jan 03 '12 at 21:21
  • 1
    Generating just templates won't improve your coverage, as the tests wont necessarily do anything. You may have to bite the bullet, and write individual tests. The templates will probably obscure what tests you still need to write rather than really help. – Atonewell Jan 04 '12 at 16:03

2 Answers2

4

Google CodePro Analytix eclipse plugin can generate the unit tests automatically for you and it is actively maintained.

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
  • This seems tightly coupled to eclipse. will try the nat tasks.. http://stackoverflow.com/questions/5632930/how-to-execute-google-codepro-analytix-from-command-line – Jayan Dec 21 '11 at 07:30
  • As of now, using codepro looks distant. It shows error message to look in logs. I cannot find any logs. – Jayan Dec 30 '11 at 17:55
1

you can try netbeans tools too, select the class and right click tools/create Junit Test but its manual and ugly task to thousands files

Grubhart
  • 1,106
  • 13
  • 19