How to automate NUnit tests in an ASP.NET website project? - asp.net

I have a client who has a large existing application written in ASP.NET, which is setup as a website project in Visual Web Developer 2010 Express.
I have been asked to demonstrate how to write unit tests and to help configure the Hudson build environment to run these tests automatically.
The code is reasonably well structured and although it does not use any UI patterns there is good separation. Business logic tends to sit inside separate classes rather than within the .aspx or associated code-behind files.
Nevertheless, as a website project rather than a web application, DLLs are not generated so the tests we have written cannot be run by the NUnit GUI.
I would like to be able to run the tests before check-in.
I would like to run the tests automatically as part of the continuous build process.
I cannot change the project type to a web application as there are downstream processes that are dependent on the project type.
Whilst upgrading to Visual Studio Professional is being investigated, I have to assume for the purpose of this exercise that I will need to make it work on VWD.
What are my options to achieve this, given the constraints above? Is it even possible?
TIA

Related

Testing ASP.NET site using WatiN. Is it possible to programmatically deploy an ASP.net site locally?

I would like to use WatiN to test the functionality of a website I'm developing. Ideally, I would programmatically deploy the website (asp.net MVC3) before the tests start running, and then refresh the data before each test. Is this possible?
Read here about using MSBuild to deploy web projects. Getting your application into automated deploy on build success (read: Continuous Integration) is really nice.
MSBuild - How to use MSBuild to deploy an ASP.NET MVC application
Using NUnit, for refreshing the data before each test you can decorate a method with [Setup] (or [TestFixtureSetup]) to run code once before each test (or once before each group of tests). I use this for cases that require specific data setup and it works like a champ. I'm assuming other XUnit frameworks have similar mechanisms in place.
Setup - http://www.nunit.org/index.php?p=setup&r=2.2.10

Web ui (ASP.NET based) to run integration tests written for NUnit

I want to be able to run and see the results of NUnit-based integration tests using some ASP.NET based UI (as opposed to regular windows based NUnit GUI). Is there an open source or commerical package already available? Note I'm not talking about testing ASP.NET or web apps.I want to run tests in code behind but see the results in Web browser
Have you considered using a ALM tool like TeamCity?
If you setup a build to run your unit tests you would be able to view the results after they run..
http://www.jetbrains.com/teamcity/
Check out CruiseControl.NET which will allow you to display the output of NUnit tests after execution.

Sharepoint WebPart

I'm new to developing in SharePoint and would like some tips please. I want to develop a WebPart. I understand that I effectively need to do this on a machine with SharePoint Server installed and create the web part as an ASP control. Once the control is created, how do I link it into SharePoint?
I would recommend you to take a look at the WSP Builder extensions for Visual Studio. It will simplify the development and deployment process for you, since it contains both templates for web parts, features and it will also package it up in a WSP solution for you.
I would read though this:
http://msdn.microsoft.com/en-us/library/ms452873.aspx
It will answer a lot of your questions about creating a web part, deploying etc.
If you're using the Microsoft Provided WebPart Visual Studio template...it will automatically be deployed to your site when you build it.
If you need to deploy to a test/production environment, you need to create a SharePoint Feature and then deploy the Feature to the server.
http://www.allaboutmoss.com/index.php/2010/03/22/hello-world-sharepoint-webpart-for-beginners/ helps you to create simple webpart and shows how it deploy in server.
You are able to build Web Parts in a number of different ways, through Visual Studio .NET using either the SharePoint Web Part Namespace or the normal ASP.NET Web Part Namespace further you are able to build Web Parts in SharePoint Designer using a combination of different technologies, such as XML Web Services.
XML Web Services will allow you to hook directly into SharePoint using SharePoint's Native Web Services, you can then create a Data View Web Part which will enable you to view, collate, filter and group List Items. This, of course, will also allow you to mingle normal HTML as well as XSLT syntax, allowing you to build logic into the Web Part.
The good thing about doing it this way is there is no "real' coding, i.e. no Code Behind page etc as there would normally be in ASP.NET. This also allows you keep things more or less SharePoint Centric, which is important because you may or may not have access to Central Admin or SSP nor indeed the Server itself, the 12 hive or the GAC.
How you decide to develop Web Parts should include thinking about all of the above, you may have a very restricted development environment. Further, you can also use Namespaces provided directly from GAC assemblies provided by Sharepoint, you may either need access to a development environment which has a MOSS or WSS Server on it or the PIA's or Assemblies from a MOSS/WSS Server.
I am a software developer, however, it is important for me to develop applications which are as SharePoint centric as they can be, which is why I decided to develop my Web Parts in SharePoint Designer. However, there have been times when using full VS.NET is the way to go, I would suggest you look at SharePoint Designer first, get a feel for the interface, XML Web Services, XSLT and HTML once you have created a SharePoint Designer Web Part and Provided this Web Part exists within a Web Part Zone, you can export the Web Part and reimport it into any number of Site Collections.
I must add that the above relates to SharePoint Lists and Libraries but it gives you a grounding to understand how it all fits together. it helped me understand more and made development of more coded Web Parts easier, It may not suit your individual requirements, SharePoint is a huge environment offering many paths.
Hope this Helps you out, search for SharePoint Designer... at least as a starting point.
Cheers

Simplifying publishing multiple ASP.NET Web Site Projects in VS2008

I have a solution in Visual Studio 2008 that contains three projects: a C# Library and two ASP.NET Web Sites (call them A and B). Web Site A depends on the library, and Web Site B depends on Web Site A.
This means that if I make a change to the library project, I have to build it, then publish A, and then publish B. Similarly, if I change A, I have to publish it and then publish B in order to push my changes through.
Is there any way to make this a one-click process for the entire solution? Basically I'm just looking for a way to, in one opaque step, build the library, build/publish A, and then build/publish B.
I have looked into the Web Deployment Project option and it does not do what I need - as far as I can tell, it kind of does the opposite (highly customized build & deployment for a single web site, rather than pretty much default-config building/publishing for multiple projects all at once).
I believe that Web Deployments projects will work for multiple projects within the same solution.
http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx
If you look at his examples, you can see that he has a website project or WAP as well as a C# library within the same solution, and he seems to be able to compile and deploy them all together.
You could probably also use multiple WDP within the same solution configued to do multiple things.
Basically the best way is to forget clicks and make this single-step deployable from the command line. Check out MsBuild to build the solution, then possibly the aspnet_compiler for build/deploy usage.

What is the best way to rollout web applications?

I'm trying to create a standard way of rolling out web applications for our company. Currently we do it with zip files, vbscript/javascript, and manual some steps.
For thick client installs we generate MSI installers using Wise/Wix. We don't create installers currently for websites as in general they are just xcopy deploy. However we have some config files that need to be changed, verify that certain handlers are registered in IIS... The list goes on.
Do most people use MSI installers for web applications as well, or some other tool/scripting language?
I recently spent a few days working on automating deployments at my company.
We use a combination of CruiseControl, NAnt, MSBuild to generate a release version of the app. Then a separate script uses MSDeploy and XCopy to backup the live site and transfer the new files over.
Our solution is briefly described in an answer to this question Automate Deployment for Web Applications?
Do consider MSDeploy, that is the direction Microsoft will be investing in the future for deployment of web applications...
Know more about the future direction at Overview Post for Web Deployment in VS 2010
We have been using FinalBuilder (www.finalbuilder.com) for this purpose for long time and for some time also using InstallAce (www.Installace.com) for build deployment on the Web Farm.
You may want to look at:
How do I get a deployable output from a build script with ASP.NET
Step by Step ASP.NET Automated Build/Deploy
We use MSI to create basic installers for our web projects too, often using the Web Setup Projects in VS and sometimes completely custom installers. You may also want to look at MSDeploy.
We're moving to an MSI for our installs, so far with mixed results. I'm a control freak so I would personally prefer a series of scripts that I had more direct control over. I've used ANT in the past with good results.
Have you checked out NAnt and CruiseControl?
Combined, they can provide an easy and automated way to build and deploy your web apps.
I work for a state agency and we do all our deployments using a product called RepliWeb.
It works good because as dev's we have no control over the webservers. But we can deploy to a deployment area and run the RepliWeb job to do the deployment. Not sure on pricing though...

Resources