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.

I never used an automated test mechanism in any of my projects and I feel I'm missing a lot. I want to improve myself, so I have to start tackling some issues I've been neglecting like this and trying Git instead of being stuck on SVN.

What's a good way to learn TDD? I'll probably be using Eclipse to program in Java. I've heard of JUnit, but I don't know if there's anything else I should consider.

share|improve this question

closed as not a real question by gnat, Kilian Foth, Dynamic, ChrisF May 25 '13 at 15:23

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

5 Answers 5

up vote 15 down vote accepted

You could start by working on coding katas. Pick an algorithm (e.g. decimal-to-Roman numeral conversion, scoring a bowling game, Conway's game of life, etc.) and try to use TDD to work on the solution.

Your solution structure will likely to be very simple (much simpler than your real-world production code): one class for the test fixture and one class containing the algorithm under test. And the class under test having no dependencies is another plus. You could use the simplicity of this setup to quickly get the hang of the red-green-refactor loop.

Which tool you use for your TDD katas doesn't really matter as long as you stick to the principles. However, JUnit plugin for Eclipse is very easy to use, so it's an excellent choice.

share|improve this answer

Get familiar with AAA, read about it, read about the issues that come with test driven development ( design for testability vs high cost tools so that the design doesn't matter). Learn Dependency Injection so that removing external dependencies for testing becomes simpler.

Here's a good overview of notes I took while reading The Art of Unit Testing

http://imaginarydevelopment.blogspot.com/2010/01/unit-testing-reference.html

share|improve this answer
1  
+1 for recommending The Art of Unit Testing. In my opinion one of the best books to explain unit testing without scaring away the readers. –  Anne Schuessler Nov 16 '10 at 8:06

There is really no substitute for just grabbing a test harness (like NUnit), reading some of the literature and then getting your hands dirty.

As James T. Kirk once said, "We learn by doing."

share|improve this answer

I highly recommend this book: Growing Object-Oriented Software Guided by Tests

It has a worked example running through the book and provides a very coherent view of when test should be created, what they ought to contain and how they should be constructed and refactored.

share|improve this answer

Check this link. It is Bob Martin's blog on TDD - excellent stuff to get you understand (or give you another prospective on) thinking in TDD.

share|improve this answer
1  
The blog's tag line, in Uncle Bob's own words, is "Writings on Clean Code, Design, and all things software." The blog content is much broader than OP's "any tips for beginner [in TDD]." –  azheglov Nov 10 '11 at 2:27

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