I’ve been working on a project using XNA recently, and since I’ve been learning TDD and unit testing I wanted to use NUnit. However, whenever I tried to load the test assembly in the test runner, I’d get the following (rather unhelpful) error:
Could not load file or assembly 'Spladug.Project.Tests' or one of
its dependencies. The system cannot find the file specified.
After poking around for a while, I discovered that my problem stemmed from being on Windows x64. XNA’s libraries are 32-bit only, which means that despite being .NET, applications (and class libraries) built on XNA are always 32-bit. As described in a post about testing 32-bit applications on Windows x64, you have to configure NUnit to run in 32-bit mode as well to be able to load the test assembly.
To do this, simply run the following command in a console with sufficient permissions and with filenames tweaked as necessary:
C:\>corflags "C:\Program Files (x86)\NUnit 2.5\net-2.0\nunit.exe" /32BIT+
corflags is a utility that comes with the .NET Framework SDK. See the documentation for .NET Framework Tools for more details.