Separating out unit tests

This question came up on a customer chat today. It’s probably interesting to a wider audience, so I’m posting it here.

I'm currently doing TDD with NUnit. With the upcoming testing tools in Whidbey, how do you see the separation of tests from production code taking place? I'm curious about how best to develop tests and then not deploy them.

Any of the techniques for test separation that work in NUnit will continue to work with Burton Unit Testing.

  • You can put the tests under #if, and toggle the flag for release builds.

  • You can put the tests in a separate netmodule that you either alink in or don't. (New features in Whidbey make doing this easier, too.)

  • You can leave them in the assembly and ship them to customers, if that suits you.

You also have some 2 new options:

  • Put the tests in a separate "friend" assembly, using the System.InternalsVisibleTo attribute.

  • Use the new Whidbey feature that generates reflection-based wrappers for your classes. This allows you to "violate" accessbility settings within your unit tests.

Overall, the behavior of the unit testing in Burton and NUnit are very similar. If you're comfortable with NUnit, it should be very easy for you to make the transition.