The other day I wanted to learn something new so I decided to try a little Unit Testing using Microsoft .NET. After looking at different Unit Testing Frameworks I chose to use NUnit Framework. I then tried an example found on the web and after the project was built, I loaded NUnit GUI and opened unit test assembly, but to my surprise, the NUnit GUI was giving me Error message. It was telling me that the Test load failed with detailed error: SystemApplicationException: Unable to find test in the assembly.
In the end I found three different ways to make NUnit work and each one will be shown in this article.
NUnit GUI was giving me this error popup window:
So to make NUnit stop showing that annoying error message, try one of the fixes below:
Set your unit test project to target .NET 3.5 Framework or less
This problem seems to occur only when your unit test project is targeting .NET 4.0 / .NET 4.5 Framework. If the project can be made in .NET 3.5 or less, you could choose this solution. You set the target Framework by right-clicking your project then choose Properties. Under Application you have an option for Target Framework.
Edit nunit.exe.config file
If changing target Framework is not an option, you can modify
nunit.exe.configfile located in NUnit installation folder and add supportedRuntime element inside startup tag like this:
<startup useLegacyV2RuntimeActivationPolicy="true"> <!-- Comment out the next line to force use of .NET 4.0 --> <supportedRuntime version="v4.0.30319" /> </startup>Note:With my configuration NUnit folder is located at:
C:\Program Files (x86)\NUnit 2.6.2\bin. Since you are modifying file in
Program Files (x86)folder, you must run your text editor as Administrator, otherwise you will not be able to save the changes.
make Firewall unblock nunit-agent.exe from accessing localhost
When NUnit runs tests in a separate process it uses
nunit-agent.exeprogram. This happens when the program needs to be run under a different framework or version from the one being used by NUnit itself. My Firewall had silently blocked
nunit-agent.exewhich was trying to connect to the 127.0.0.1. Once it was able to connect, the NUnit was able to find the assembly without any problems.