Load Testing WCF Services using Visual Studio – Part 1

Share on facebook
Share on twitter
Share on linkedin


This is a two-part series that covers using Visual Studio to load test a WCF service. In part one of this series I will cover how to create a project and unit tests; part two covers creating and executing the load test.

A recent project involved the development of several Windows Communication Foundation (WCF) services, my role was Lead Software Tester. I was charged with not only testing them for quality but also load testing the services. In this article I’m going to cover how we approached load testing the WCF services using Visual Studio 2013. The benefit of using Visual Studio is that, among other things, there are a number of features available for both orchestrating the tests as well as producing useful charts and graphs for analysis.

Our client provided us an SLA in terms of required throughput, so we calculated the necessary performance needed to achieve the throughput across all services. Acceptance criteria specifically stated the solution being developed would need to meet this SLA.

Getting Started

As soon as the development team started producing services, it was time for the testing team to begin to measure the performance of these services against the SLA. I started by creating a Visual Studio 2013 project comprised of the following:

  • Project based on the Web Performance and Load Test Project template, with references to each of the services.
  • Unit tests for each method call that needed to be measured.
  • Load tests for each of services.

Creating the Project

I created a project based on the Web Performance and Load Test Project template. This is where I will create the unit tests for the various methods in each WCF Service. The reason to use the Web Performance and Load Test Project template is, as you Add new items to the project you see all the available testing items from which to choose (See Figure 1).


Figure 1 – Available Items you can add in the Web Performance and Load Test Project template

Before creating a coded unit test, I’ll need references to the services. Once the references have been added, I’ll be ready to create unit tests for each of the service methods.

Creating unit tests

The unit tests will be used in the load tests but need to be created before we can create a load test scenario. Figure 2 shows an example coded unit test that calls the service. As most unit tests do, I was sure to include Assert statements that provided me with the necessary success or failure status of the test. Note that when a response is received and the response does not contain “fault” the test succeeds and when an exception is caught the test is automatically failed. These results are neatly passed to Visual Studio for presentation in the Test Explorer; shown in Figure 3.


Figure 2 – Unit test method

Once all necessary unit tests have been created, build the solution. When the solution is successfully built, all the tests are discovered and become visible in the Test Explorer. See Figure 3. The Test Explorer shows the available tests and their status. This is also a good time to individually execute the tests and ensure they are running as expected.
Note: It is important to build the solution once before trying to create a load test otherwise your tests won’t appear in the Test Explorer or be available for selection in the load test wizard.


Figure 3 – Test Explorer showing available test methods and status

The Test Explorer is a great way to spot check the tests by executing them and reviewing the results.


This article showed how to create unit tests that can be used as components of a load test in Visual Studio. Part 2 of this series will show how to use these to build a load test and measure the performance of the solution.

More to explore