I need to do some functional testing on a component that exposes a small set of WCF endpoints. I'm still ramping up on WCF, so I'm hitting a bit of analysis paralysis trying to figure out the best way to test this. In doing some research, most articles approach this from a unit testing standpoint. I've seen some people say to completely avoid the WCF plumbing and just test the interface implementation directly, which seems more like unit testing to me. Others recommend to have the test case(s) use WCF self hosting and make the calls. Any guidance or wisdom on testing APIs that are exposed as WCF?
There are two approaches that I have taken to testing a WCF service. I am working under the assumption that you are looking to simulate the configuration both hosting and access that an application would do from a production set up. Hosting it I would set it up in a similar maner to what you are planning to do when deployed. For me this meant deployng it to a server and the hosting was done either though IIS or as a windows service deployment .
Once this is done it sort of depended on what I was trying to accomplish. If I just wanted to do some quick and dirty testing of the service I used the WCF Test Client. This allows me to simply pass input values to the available methods and look at the return values. If I was writing automation I simply started a new project in VS and added the hosted service as a reference and started writing my code against the exposed interface. Hope this helps
I use SOAP UI for this. It automaticaly generates all the functional test cases, based on wsdl definition, it is possible to load test your service, it is free and open source (and there is commercial version), etc.
Below options are also a possible solution:
Generate a client proxy class for the WCF Web service
For .NET 2.0 testing I have used VSTT for web service testing. It is pretty simple. See Creating a Data-Driven Web Test against a Web Service.