Unit test project doesn't recognize the classes it was generated from
Posted
by DougLeary
on Stack Overflow
See other posts from Stack Overflow
or by DougLeary
Published on 2010-04-05T18:03:28Z
Indexed on
2010/04/07
20:33 UTC
Read the original article
Hit count: 281
unittest
|visual-studio
I have a fairly simple file-system website consisting of one aspx page and several classes in separate .cs files. Everything is on my own HD. The web app itself builds and runs fine. Out of curiosity I decided to try out Visual Studio's nifty, easy-to-use unit test feature. So I opened each class file and clicked Create Unit Tests. VS generated a test project containing a set of test classes and some other files. Easy! But when I try to build or run the test project it throws a series of build errors, one for every class:
The type or namespace name 'class-name' could not be found (are you missing a using directive or an assembly reference?).
Somebody asked if my test project has a reference to the original project. Well no, because the original project is a file-system website. It has no bin folder and no DLL, so there's nothing to reference as far as I can tell. I would think that since VS generated these unit tests it would generate whatever references it needs, but apparently not. Is generating unit tests for file-system web apps an undocumented no-no, or is there a magic trick to getting it to work?
© Stack Overflow or respective owner