Search code examples
visual-studio-2010unit-testingvs-unit-testing-framework

Unit test Website Application in Visual Studio 2010 vs Web Application


I have a project that is currently a "website" application but need to use Unit Testing. I notice on the majority of examples for unit testing seem to show only web applications.

  • Would it be best to convert to web "application" first?
  • What would be the pros and cons?
  • What is the preferred way to develop and have unit test on a Visual Studio 2010 project(web applications or Website applications)?
  • Do you see performance increase in both Testing/Development under Web App Projects?

One thing I noticed immediately is that in Web Application it simplifies testing because of the namespace formatting/generation. When you generate an auto-test using the wizard you get nice clean code. (i.e. Employee class references the correct namespace...etc)

Ex:

Employee target = new Employee();

Whereas in website application when you reference the code base for a class you get the following:

Employee_Accessor target = new Employee_Accessor();

and this:

    [Shadowing("Employee")]
public class Employee_Accessor : BaseShadow, 
        INotifyPropertyChanging, INotifyPropertyChanged
{
    protected static PrivateType m_privateType; ...

Solution

  • The real question here is the difference between a Web Site Project vs a Web App Project.

    If you read this detailed and clear explanation at MSDN you will notice that MS recommends WAP over Web Sites and why.

    So, to answer your questions:

    • It is better to convert to a WAP first.
    • Advantages - See the link above.
    • Your 3rd question isn't clear to me. If you need a basic how to then here it is.