Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

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

share|improve this answer
    
Based on your first paragraph, it makes sense to host the service in IIS as we do in production and test against that. Thanks! –  Nithin Shenoy Jun 8 '11 at 16:01
    
Just as a follow up, I decided to host the service in IISExpress. This made the test deployment model really easy and portable. One of the gotchas is that IISExpress only supports http/https bindings, so this won't work if you need to test other bindings like net.tcp. –  Nithin Shenoy Jun 17 '11 at 3:35

Below option is also one possible soultion

  1. Generate client proxy class for the WCF Web service

  2. Using VSTT - Data Driven Test Approach for running tests with different test data - http://msdn.microsoft.com/en-us/library/ms182527.aspx

  3. For .NET 2.0 testing i have used VSTT for web service testing. It is pretty simple Creating a Data-Driven Web Test against a Web Service - http://blogs.msdn.com/b/slange/archive/2008/05/23/creating-a-data-driven-web-test-against-a-web-service.aspx

Hope it helps

share|improve this answer

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.

http://www.soapui.org/

share|improve this answer
    
Thanks Nikita. I briefly looked into this and it's not exactly what I'm looking for. I'm looking more for approaches/methodologies for structuring or architecting my automated testing. I'm currently going the self-hosting route for now, but I'll continue to look into SOAP UI. Thanks! –  Nithin Shenoy Jun 7 '11 at 1:56
    
@Nikita, just to clarify: SOAP UI, creates templates for a functional test case, not test cases themselves. –  dzieciou Apr 13 '13 at 7:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.