I’m currently trying to upgrade our build server at work, going from having no build server to having one!
I’m using JetBrains’ TeamCity (having used ReSharper for a couple of years I trust their stuff), and intend to use NUnit and MSBuild.
However, I’ve come up with an issue: it appears that it is not possible to test an ASP.NET web site with NUnit. I had assumed it would be possible to configure it to test App_Code after a build, however it seems that the only way to do tests nicely is through converting the web site to a web application (which my boss does not like the idea of).
How could I go about this?
Please bear in mind that the testing needs to be able to be fired automatically from TeamCity.
If you want to smoke test your site, or bang on some endpoints – see the code below.
If, on the other hand, you want to test the untestable (detestable) ASP.NET website assembly (as opposed to a web app), you are, as they say in France, S.O.L.
The assembly is a randomly named dynamically compiled assembly deep in the bowels of the framework temporary ASP.NET files, making testing close to impossible.
You really do need to consider a couple of options:
Sorry, I don’t think that you will find what you are looking for, but I could be wrong. Let’s see.
Good Luck
Download Visual Studio 2008 sample with site and applicatgion.
I wrote a wrapper for
WebHost.WebServer.dllwhich is the core of the development server that works quite well in CI. I use it all the time.Here is a scaled down version including a usage example.
Test.cs
WebHostServer.cs
NOTE: The
Microsoft.VisualStudio.WebHostnamespace is contained in the fileWebDev.WebHost.dll. This file is in the GAC, but it is not possible to add a reference to this assembly from within Visual Studio.To add a reference you will need to open your .csproj file in a text editor and add the reference manually.
Look for the
ItemGroupthat contains the project references and add the following element:Reference: http://www.codeproject.com/KB/aspnet/test-with-vs-devserver-2.aspx