Search code examples
visual-studiowcfiis-7nunitcassini

Forcing loading of Asp.net development server with DEBUG for testing wcf service (nunit)?


can anyone help?

I have a solution in vs 2010 which contains a WCF Service application and a class library which has a number of Nunit test.

The nunit tests the service. Problem is that there is no Asp.net Development server running - is it possible to force it to run under debug mode..

I can press F5 but then i can't run my tests.

Maybe i am doing this all wrong, should i host them under IIS 7 ? rather than the built in development server.

That way the server is ALWAYS available rather then loading on demand


Solution

  • See http://www.codeproject.com/KB/aspnet/test-with-vs-devserver-2.aspx for a very lightweight and, in my biased opinion, elegant way to integrate webdev/cassini into your testing environment.

    NOTE: the first example of controlling the .exe is for edutainment purposes only. Read through to the second, very brief, code sample for the money shot.


    Update:

    I use the technique listed above with nunit and most every unit test runner around, including continuous integration on servers that I do not control, extensively with great results.

    When I need to simulate a real server with a host name and non-loopback ip address, which WebDev.WebServer and WebDev.WebHost cannot do,

    • I add the host name to my hosts file, e.g. localhost.skysanders.net 192.168.0.10
    • use the CassiniDev .dll in almost exactly the same way

    it is so simple and bullet proof it should be illegal. ;-)

    CassiniDev is also a perfect replacement for the WebDev.WebServer.exe for VS 2008/2010. It has integrated traffic monitoring and is quick a bit faster, both at startup and at processing.