eugeneK
eugeneK

Reputation: 11136

Unit testing WCF calls, is it possible and how?

I'm working on a tool that checks some large application functionality. All of my calls to large application are made using WCF, application is too big to create Mock out of it. I want to create Unit Tests for my tool so i won't break functionality while re-factoring or extending functionality.

Is it possible and how ?

Upvotes: 2

Views: 122

Answers (3)

Ira Rainey
Ira Rainey

Reputation: 5209

I guess it depends whether you're looking at unit testing the classes behind the service or functionally testing the service itself.

For functional testing of WCF services I use WCF Storm which could do with a little polish, but works great. You can build and run functional tests as well as performance tests. Very useful little tool.

http://www.wcfstorm.com/

Upvotes: 0

Oliver Weichhold
Oliver Weichhold

Reputation: 10306

The phrase "application is too big to create Mock out of it" raised a warning sign. I do not mean to sound harsh but if your application logic cannot be broken down into smaller unit-testable parts then there's something wrong with the architecture of the application.

I've been unit testing WCF powered Silverlight ViewModels for years using Moq with great results. A concept which can be applied to ASP.Net/MVC as well.

Upvotes: 0

Christian Hayter
Christian Hayter

Reputation: 31071

You can, but they won't be unit tests in the normal sense of the word, they will be more like automated regression tests. A typical test method might contain the following:

  1. Write expected test data into the database
  2. Make the WCF call
  3. Read data out of the database and assert that it's what you expect
  4. Reset the database if necessary

It takes a lot of care to get this right, but it does work.

Upvotes: 1

Related Questions