views:

31

answers:

1

I hope this I can explain what I am trying to achieve: I want to be able to create a unit test in the same solution as my web service, have it fire up the web service environment and be able to set breakpoints in the unit test code and in the web service code and have the debugger stop on both of them. Is this possible?

+1  A: 

I've done it once, and it was a huge pain with little benefit. I recommend against it. There are a couple of edge cases that actually testing the serialization will catch, but most of those (with the possible exception of passing large amounts of data) will be found during acceptance testing.

My recommendation would be to keep your webmethods as bare as possible, down to a line or two of code if you can. Move all of your business logic to one or more Plain Old CLR Objects (POCOs). Those can be in the same project as your web service or in a separate class library (in the same 2008 solution is fine); separation would allow for more reuse.

Create another class library (again, in the same solution) for your unit tests. Have it reference only the business logic library. Tests against those methods will be relatively fast.

The webmethods might contain some simple logic (convert arrays to lists, create objects, etc.), but try to keep them simple enough so that they are unlikely to break.

You can use breakpoints with a test integration like ReSharper, or simply by running NUnit and attaching to the process in the VS debugger. (Probably similar for other test frameworks.)

WCF might be worth looking into as well; I think it has some features that might help you. (I'm not a WCF expert.)

TrueWill