Testing WCF Services – Basic Functionality

This past week I just finished writing up an article for MSDN Magazine (http://msdn.microsoft.com/msdnmag/) that introduces the basic techniques and principles of testing Windows Communication Foundation (WCF) services. You can think of WCF services as a way to create distributed systems; or put another way, you can think of WCF as similar to Web Services but with much greater flexibility and features. Consider a WCF service which has operations that perform MD5 crypto-hashing. A crypto-hash accepts any number of bytes, which in turn can come from any type of information including text, and returns a fixed size identifying value in the form of an array of bytes. An MD5 (Message Digest version 5) crypto-hash is one of many specific crypto-hashing methods and it accepts any number of bytes and returns a 16-byte array. SHA1 (Secure Hash Algorithm) is another common crypto-hash and it returns a 20-byte array. Suppose you have several applications (perhaps Web sites and network-connected applications) that need to compute crypto-hashes. You could simply place the crypto-hash functionality into each application. Alternatively, you could use a distributed application approach (which you can also call a Service Oriented Architecture [SOA] approach) and create a single WCF service which has a crypto-hash operation. Then all you applications could call into the one server machine which hosts your WCF service. OK, so how do you test your WCF service? The most basic form of WCF testing is to verify the functional correctness of your WCF operations. One way to do this is to programmatically send a message to your WCF operation, fetch the response message, and compare the response with an expected result to determine a pass/fail result. See the screenshot below for an example. In essence the test harness is just a specialized WCF client program. In my MSDN Magazine article, which I expect to be published within about three months or so, I explain all the details of performing basic WCF testing. I also describe WCF testing scenarios that go beyond basic functionality verification, such as testing WCF security features and testing WCF transmission protocol variations. An interesting side effect of learning how to write test automation for WCF services is that the process really helps you better understand how to create and use WCF services. 
This entry was posted in Software Test Automation. Bookmark the permalink.