RESTful Client Unit Testing with NancyFX

added by jfritz
7/12/2012 8:14:04 AM

3 Kicks, 271 Views

An interesting approach to verifying the behavior of a RESTful client by using the NancyFX server to stub out the target service. A brief description of the problem with lots of sample code is provided.


7/12/2012 8:19:51 AM
Using the approach in the article, we're still prone to test failures should something go wrong starting up Nancy (this should be evident by the code that had to be written to wait and ensure it has started). What can you do if Nancy fails to start? Fail the test? Then you have to spend time diagnosing why it won't start, when all you really need to do is stub the GetOrders function to return a static list of orders.

7/12/2012 9:06:46 AM
I would have to agree with the above comment. I like to do my unit tests ensuring everything works within methods the way it is supposed to first. From there, any web service communication can be isolated and tested for accuracy. Seems like with Nancy, you are adding one more layer that may or may not be the problem at hand.