Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Currently, I am working on a very complex product. Unit testing is something unknown to this product till date. Hence the code base is too complex to keep it compatible with unit tests. I am supposed to develop a TDD framework for this product so that at least the newly written code will be thoroughly tested by unittests.

I am a newbie to the world of TDD and unit testing as well. I am going bonkers trying to wrap my head around the testing frameworks and tools available. My current focus is on code coverage that generates a complete report about package level, function level, and branch level coverage. The code base is targeted to java or groovy. I was going through Cobertura and some other tools and frameworks but I hardly know the goods and bads of each, as I am a newbie. Please suggest a good framework/tool that is apt for my needs.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

You basically need two three things:

  1. Working Effectively With Legacy Code by Micheal Feathers. This book is the bible for such situations, even for developers with prior unit testing experience. (I was one of these, so for me it was easy enough to read - if you are totally new to unit testing, you might want to read through a beginner level book on the subject before, though.)
  2. A unit testing framework. JUnit is the classic, and it still works fine, although some prefer TestNG. I think either of these is good enough.
  3. A mocking framework, although not absolutely essential, will make your life substantially easier. There are more of these on the market. Our team uses EasyMock and I like it, but some say there are better ones.

These three are enough for you to get started. I wouldn't worry much about code coverage until you have a couple hundred working test cases. In the beginning, your most important task is to learn the tools above, absorb the mentality, learn how to wear the tester's hat. During this time, it can in fact be very depressing to see you achieved 0.1% coverage with several days' hard work...

But to answer your concrete questions, we use Clover and I am happy with it. It supports both Java and Groovy, integrates with Ant, Maven, Bamboo, Sonar and other build / CI tools, and also has IDE plugins for Eclipse and IntelliJ. Only problem is, it is not free...

share|improve this answer
add comment

I've been happy with the eclEmma code coverage plug-in for Eclipse. There's also a plug-in that works with Jenkins so you can automatically generate coverage statistics from your builds (assuming you run your unit tests as part of your builds).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.