views:

235

answers:

2

I am new to unit testing and I wanted to give NUnit a try.

In an ASP.NET Web Project, I can create a new project in my web project solution for unit testing and add a reference to my original project and in NUnit I can load the dll file for my unit testing project to run the tests.

However, i am developing an ASP.NET Website and because an ASP.NET Web Site does not have a dll file, I cannot add a seperate project in my solution which references my website project, and therefore, I was not able to access classes in the main project to test. Even if I decided to leave my tests in my main web site project, I am not able to directly load the dll for the web site in the NUnit Gui (because there isn't any dll file).

I also face a problem when i try to creat Unit Tests for my web site using Visual Studio, don't know if they're related.

Any help would be apreciated.

+4  A: 

Why can't you switch to Web Application Project instead? Or, you can move your business logic to an external Class Library Project and then reference the latter in your Nunit Test Project.

Kerido
So unit testing ASP.NET Web Sites is not possible?
bahith
It may be possible with the published version of the web site. That way, you have a DLL that you can link against in the Nunit Test Project. However, it's a pretty awkward solution. I actually have negative impressions about the Web Site Projects at all.
Kerido
Thank you very much.
bahith
A: 

You can provide the reference to your website project by add reference->projects-> add project.

Shashi