Is unit testing a bad idea during beta/prototyping?

I've found that thoroughly testing early results in lots of code thrown away and an empty feeling in the pit of your stomach.

Test what needs to be tested and not a line of code more. When you figure out how much that is, let me know.


The short answer is that TDD is very valuable for beta versions, but may be less so for prototyping.

I think it is very important to distinguish between beta versions and prototyping.

A beta version is essentially a production version that is just still in development, so you should definitely use TDD in that scenario.

A prototype/proof of concept is something you build with the express intent of throwing it away once you've gotten the answers out of it that you wanted.

It's true that project managers will tend to push for the prototype to be used as a basis for production code, but it is very important to resist that. If you know that's not possible, treat the prototype code as you would your production code, because you know it is going to become your production code in the future - and that means you should use TDD with it as well.

When you are learning a new technology, most code samples etc. are not written with unit tests in mind, so it can be difficult to translate the new technology to the unit testing mindset. It most definitely feels like a lot of overhead.

In my experience, however, unit testing often really forces you to push the boundaries of the new technology that you are learning. Very often, you need to research and learn all the different hooks the new technology provides, because you need to be able to isolate the technology via DI or the like.

Instead of only following the beaten path, unit testing frequently forces you to learn the technology in much more depth, so what may feel like overhead is actually just a more in-depth prototype - one that is often more valuable, because it covers more ground.

Personally, I think unit testing a new technology is a great learning tool.

The symptoms you seem to experience regarding test maintainability is a bit orthogonal, I think. Your tests may be Overspecified, which is something that can happen just as well when working with known technologies (but I think it is probably easier to fall into this trap when you are also learning a new technology at the same time).

The book xUnit Test Patterns describes the Overspecified Test antipattern and provides a lot of guidance and patterns that can help you write more maintainable tests.