The Microsoft unit testing framework comes with the MSTest.exe to run tests from command-line. This only works on machines that have Visual Studio installed. With some tweaks you can make it run on a computer without Visual Studio (see here). But that requires to add some keys to the registry and copying a bunch of assemblies which might not be an option for a pre-production or production environment.
So I decided to write a little command-line application that runs all tests in an assembly. You can download it from codeplex. It basically does the following:
- Load assembly with tests
- Load configuration file for assembly
- Find all classes marked with the TestClass attribute
- Find all methods marked with the TestMethod attribute and execute them
A failing assert statement will throw an exception which the test runner application handles. So counting the passed and failed tests is trivial such as measuring the execution time with a Stopwatch.