views:

103

answers:

3

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

A: 

I haven't tried this but since you haven't gotten any other responses:

http://xneuron.wordpress.com/2009/03/27/launch-cassini-using-command-line/

This looks like a command you could add as a pre-build step to your NUnit tests. Hopefully Resharper honors those commands and ensures they're run before doing its own test-specific builds.

roufamatic
A: 

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.

Sky Sanders
A: 

I have a solution with exactly the same layout. I would much rather test them in IIS since that is where they will be deployed, and it's nice to know that the code definitely runs under the restricted IIS account rather than my domain account. I run the unit tests as follows:

  1. Make sure IIS is running.
  2. Right-click on the WCF Service project and Publish to IIS.
  3. Fire up NUnit on the client test project and run the tests.
  4. If all tests pass, then great, Otherwise...
  5. Leaving NUnit open, switch back to Visual Studio, and attach the debugger to the IIS worker process (aspnet_wp.exe on my dev machine).
  6. Switch back to NUnit and re-run the failed tests. Any exceptions and breakpoints will break into the debugger as normal.
  7. Rinse and repeat as many times as you like.
Christian Hayter