Everything works fine when the unit tests class is part of the main project (TestAccount).
Every article I’ve read about unit testing recommends putting the tests in a separate project, so I…
- added another project (TestAccount.UnitTests) to the solution
- moved the unit tests class (AccountTests.vb) to TestAccount.UnitTests
- and added a reference in TestAccount.UnitTests to TestAccount (copy local = true)
The solution compiles without any warnings. However, nUnit can’t access the main project and gives the following error for each test:
System.IO.FileNotFoundException : Could not load file or assembly ‘TestAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
What am I doing wrong?
(I was having similar trouble with nunit.framework.dll until I added it to the GAC)
screenshot of Solution Explorer http://img440.imageshack.us/img440/4862/nunitsolutionexploreree3.jpg
Visual Studio 2005
.NET 2.0
nUnit 2.4.8 (.NET 2.0 version)
[Edit] I only have this problem when running nUnit from Visual Studio (as external command). If I load the nUnit console independently, it works fine.
[Edit] Omar: yes, I have the reference to the other project. Here is a screenshot of my solution explorer
I think I might just have to run the nUnit console separately (instead of through VS’s External Tools).
I found a bug report that says Visual Studio incorrectly expands the TargetPath and TargetDir macros. They expand to the obj\ directory, not bin\
[Update] The problem/solution is actually discussed in the Visual Studio Support section of the documentation. Since the ‘Target’ macros point to obj\, you can’t use them out-of-the-box. I ended up using the following expression in the Arguments field: