views:

95

answers:

2

Hi All, I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I would like to implement some unit testing. I created a class in the app_code folder and added Imports NUnit.Framework etc... After writing a basic test, I get the "Can't execute tests in 'Web Site' application." error. I guess the Web Site project is not supported. Converting to a Web Application is not an option at this time. I have Visual Studio Test Edition, so I tried that route. I created a test project, wrote a couple tests in my test class etc... only to find out I cannot reference the classes in the app_code folder of the Web Site project. Can anyone out there give me some pointers??? Am I doing something wrong. I am pretty new to TDD. I just want to properly implement a bit of testing on this application.

Thanks In Advance, ~ck in San Diego

+3  A: 

Create a separate project for unit tests, especially if you are using a web site.

You should probably not be unit testing the classes in your web site. Rather, any classes you'd want to unit test, should probably not be in the web site. Rather, they should be in a class library project that is referenced by the web site.

This is yet another reason to not use web sites: they do not compile until they are used, so there is no compiled version of the code in app_code for your test project to test.

Web sites should be used for nothing other than simple web sites. Anything else is more sophisticated than they were intended to handle. Use a Web Application Project instead (but still keep must interesting code out of the project).

John Saunders
A: 

I think John Saunders has sound advice. You want to try the web site a presentation layer and isolate the classes that comprise the business logic into a separate library for testing. This allows you to focus solely on the processes that the classes are intended to implement.

So you know I started out TDD with nUnit then used the MS Test suite for a major project. I would chose nUnit over MS as it was much faster.

David Robbins