Using CassiniDev with unit testing frameworks and continuous integration
Hosting a web site or application for testing purposes using CassiniDev is very simple and performs well in continuous integration scenarios.
A simple example using NUnit
- In your test project, reference the desired library, either
CassiniDev-lib.dll for an in-process server or
CassiniDev-console.exe for an out-of-process server, and extend the provided server fixtures
- CassiniDevServer wraps CassiniDev-lib which provides an in-process server suitable for debugging tests and is the preferred method of usage unless an out-of-process server is required.
- CassiniDevServerOP controls a shelled instance of CassiniDev-console that is run out-of-process.
- Start the server in your fixture setup method. You may start the server in the per test setup method if you require extreme isolation.
- Stop the server in your fixture teardown method or test teardown depending on how it was started.
- Utilize the helper method NormalizeUrl to build fully qualified Urls to resources in your application. This allows the use of dynamically assigned ports to eliminate the possibility of port conflicts.
- If you would like to debug your web site/application during unit tests simply add a reference to the site under test to the test project. Debugging is only possible with the in-process server
(from project CassiniDev.NUnitFixtures.Tests)
/// Note: this fixture leverages the in-process CassiniDev server. If you have restrictions or experience
/// issues with the in-process server, simply reference CassiniDev-console and use CassiniDevServerOP.
/// API and usage is same.
public class CassiniDevNUnitFixture : CassiniDevServer
public void TestFixtureSetUp()
// assuming your test project and web project or site are in the same parent directory
const string applicationPath = @"..\..\..\CassiniDev.TestSite";
// Will start specified application as "localhost" on loopback and first available port in the range 8000-10000 with vpath "/"
// if you would like to exercise more control simply use any of the available overloads
public void TestFixtureTearDown()
public void Test()
// normalize URL provides a fully qualified URL rooted on the currently running server's hostname and port
string url = NormalizeUrl("Default.aspx");
WebClient wc = new WebClient();
string actual = wc.DownloadString(url);
Assert.IsTrue(actual.Contains("this is default.aspx"));
// for a web testing utility library that simplifies endpoint testing see the Salient.Web namespace in http://salient.codeplex.com
Confirmed Testing Scenarios:
- MSTests using Visual Studio Test Runner.
- MSTest tests using all TestDriven runner and coverage options.
- NUnit tests using NUnit GUI and NUnit console.
- NUnit tests using NUnit VS integration
- NUnit tests using Resharper VS integration
- NUnit tests using all TestDriven runner and coverage options.
- NUnit tests in TeamCity pulling from CodePlex